Could it be an example of a tragedy of the commons?
No one wants to drink water where someone shit but everyone would rather shit in the water than in a field somewhere far and away from the ability to clean oneself.
this is it right here ... what better way to get that baby-fresh feeling than just popping a squat in the river, where the current takes away your inanimate offspring downstream, and cleans your nether regions.
Humans are creatures of habit, and often, self interest (a clean arse) will win over benefits to others (see all politics ever, almost)
Say village A is upstream from village B. A poops in the water. How far downstream does B need to be for the water to be drinkable? Or is there no safe distance? If there is a safe distance, in theory, you could teach the villages in A to drink upstream and poop downstream. By the time the water gets to B, it's clean enough to drink?! Then teach B to poop upstream and drink downstream... You probably don't want to put me in charge of public health :P
Well, the so called public defecation usually happens in a) slums b) rural areas where they have not built toilets at home. In the rural areas, they just go out into the fields which offer some privacy. It is never in the "public" like a river etc.
No one wants to drink water where someone shit but everyone would rather shit in the water than in a field somewhere far and away from the ability to clean oneself.