Which countries ? I’ve never been to a place where as an already paying customer I had to pay for the restroom. You often do see signs ‘customers only’ on the restroom though.
If I recall, it was fast food type joints in Netherlands and Germany. What blew my mind was that these places would employ someone to actually stand guard at the washrooms and collect payment. Wild behavior, in my opinion.