You can expect that someone drinking from a water source regularly will develop immunity to the pathogens in that water source by being repeatedly exposed to them.
However, it's not quite right to say that poor quality drinking water impacts mostly tourists. It mostly impacts the people drinking that water, especially children. Immunity comes at a cost. Some example statistics from Wikipedia:
Between 2000 and 2003, 769,000 children under five years old in sub-Saharan Africa died each year from diarrheal diseases
In South Asia, 683,000 children under five years old died each year from diarrheal disease from 2000 to 2003. During the same period, in developed countries, 700 children under five years old died from diarrheal disease.
And from WHO:
Contaminated water can transmit diseases such diarrhoea, cholera, dysentery, typhoid, and polio. Contaminated drinking water is estimated to cause 485 000 diarrhoeal deaths each year.
These statistics conflict a bit, and I won't go too far into the reasons why or try to identify the correct number. I think they are all sufficient to identify this as a substantial issue in the world.
Responses to disease vary between individuals for all sorts of reasons, including genetics, overall health at the time (for example, someone well-nourished versus poorly nourished), and access to medical care and treatment. Some you could also add up as effectively "luck". In a hypothetical scenario, you could expose 100 people to a pathogen, and of those 100, many may get very sick and a few die. The survivors may then have future immunity to the same pathogen, but it would be wrong to say the population as a whole is not affected by it, you're just looking at the people who survived.