When we first began going to Mexico in the early 1970s, my wife almost always got ill from the water while I never had a problem. On a flight home one year, she was so bad that the flight attendant became very concerned & supplied her with a damp towel for head.
After the first two times, her doc gave her a prescription for ampicillin & told her to begin taking one a day about two days before arriving in Mexico. It worked. So henceforth, we stocked up on ampicillin in Mex. where we didn't need a script to buy it. She never got sick again. Several other medications that kill bacteria, such as amoxicilin, will also work.