I've only seen this in larger cities with lots of people experiencing homelessness, it's more of a housing issue than anything. In most of the country, and where I live, businesses don't make you pay to use the bathroom.
I used to work for a retailer with free bathrooms, I went into the bathroom during my shift and found a homeless man half-naked giving himself a sponge bath from the sink. I startled him, he startled me. We locked eyes for a moment, it was awkward, so I shrugged and walked across the store to use the other bathroom to give him some privacy.
Businesses want to avoid those sorts of interactions, protect their bathrooms from damage, and they don't want people making messes that have to be cleaned up. The guy that I saw bathing in the sink got water all over the floor that had to be mopped up after he left. Once a few businesses restrict bathroom access every other business in the area is overburdened by people only coming in for the free bathrooms until they too decide to restrict bathroom access. In most of the US our public infrastructure completely neglects people experiencing homelessness, so their needs are passed onto businesses which also refuse the obligation.
We have a federal government that does virtually nothing for people experiencing homelessness, state governments that do as little as possible for the homeless, local governments confused and unprepared to deal with the causes of homelessness, and finally businesses (which are the least able to meet the needs of the homeless) that discriminate against the homeless.