The stall itself is robotic and self-cleaning, so one human attendant can service dozens of locations. The human labor factor is what usually torpedoes the economics of privately-owned public-access toilets, so if you can engineer the robotic functions well enough, your per-customer operating costs can drop low enough that you only need 1 in N to pay you anything to stay in business.
In actual practice the problem tends to be prostitutes using it as their workplace, IV drug users needing a private cop free place to shoot up, and homeless people.
Embracing those problems instead of ignoring them is likely to successfully generate more money.
Back when bathroom attendants were economical, they were the ones that could chase out or discourage the undesirables.
I didn't mention this, but one of the robotic bathrooms I have seen encourages people to leave in a timely fashion by filling itself with water as part of the self-cleaning cycle. That program mentioned the difficulty in getting the squatters out while still serving regular customers.
[Edit for cousin post:] After the door lock times out, the GTFO timer starts. Don't be surprised if your stall fills with unpleasant odors (mercaptans) and sprays of cold water if you decide to try to squat in there without paying.
Or a screwdriver in the latch. Don't underestimate smart apes.