There are many ways to be sick while traveling.
There is often an adjustment period to a new flora and new habits (eating, drinking, sleeping and spending the day differently). This can happen in London as easily as if can happen in Accra. But in London you are more likely to blame the extra Gin and Tonic than the water.
Then there is genuine food poisoning. I have seen a couple hundred people live for years at a time in countries without safe drinking water. There is a clear pattern.
People who eat and drink freely, under the attitude “when in Rome”, spend much of their time sick. People who mostly follow the rules but occasionally let one slide get sick from time to time (this was me.) The people who are fastidious about their water don’t get sick, or get sick rarely.
Of course, it also involves trade-offs. On a short trip, it provably makes sense to be more cautious. But if you are spending years someplace, you may decide that it’s worth the occasional bad night to be able to eat the street food.
Most urban-ish areas have some kind of water treatment. The question is how well staffed, supplied and maintained it is. Parts can be expensive and hard to source, and supplies are not always delivered on schedule.
A water pump once broke in my local “big city”,’ which left the more elevated parts of the city suddenly without water pressure. You’d leave the taps on before you went to bed, and hope that enough water trickled into the buckets overnight to get through the next day.
It stayed that way for several years. Once something breaks, it’s totally possible that it just won’t get fixed. So you can’t rely on municipal water systems.
The locals? They get sick, too. Diarrhea is still the number one killer of children. Productivity in developing countries sucks, in part because people spend much of their working lives sick. As a relatively wealthy foreigner, you don’t have to worry about the costs of wood to boil fire or chlorine to purify it, but many people don’t have ready access to even basic purification methods.
Beyond following the rules to the letter (and definitely don’t get lax just because you are at a tourist restaurant- those are often the worst because they don’t rely on repeat business), there isn’t a lot that you can do. Some doctors will prescribe Cipro for travelers, and that can stop something bacterial in its tracks, but of course won’t stop something viral. And Cipro can have some intense side-effects (I personally will never take it again.)