Take the western media's portrayal of India's poverty with a little grain of salt. India is very poor and I lived in a village where people use to shit in open but then there is something like "poverty porn" that western media often engages in to get more eyeballs.
In rural areas open shitting has its own unwritten rules. You shit far from water sources, temples and other places where people gather. You shit away from water wells. Sick people shit in a separate area.
People do shit at riverside because easy availability of water but it is essentially tragedy of commons issue and it was very common to beatup people who took a dump near potable water sources.