That is part of the dangers of foreign travel. My daughter, whose rather "tough" (but doesn't look it), when to Costa Rico with another woman had been in offshore Coast Guard (drug interdiction ship) and a Man who had recently got out of the Marines as a combat squad leader (she defines him as "a weapon" - VERY tough). They got off on a wrong road finding themselves is what they sensed a very danger shanty-area trying to figure how to get out of there.
My point is that no matter how much caution a person can show, things can go wrong (here or in foreign countries). Also, in most foreign countries unless you have CASH or the money readily available on credit card in the event of a medical crisis or accident injury, they'll let you die as they don't treat a person without pay.
The only country we travel to is the Bahamas, for which except in a major criminal case they prefer to just ship you back to the USA and bar you ever coming back, and Miami for hospital is close for airlifting for medical care, plus since the Bahamas is a rich folks haven they do have excellent medical facility. But even there, there is the "good" parts of the Bahamas and the rest tourists are advised to stay out of.
"Staying safe" when touristing - particularly if a non-English country, a person has to fairly stay on the tourism path, which I tend not to care for.