Criminal doesn’t mean stupid - and you’re not going to bother with a risky target when there are other, less risky targets nearby.
1) If there is a dog on the boat, maybe there's people too.
2) Plenty of other boats, why bother killing a dog and make lots of noise?
Exactly. A lot of people seem to forget that a gun discharging is even louder than a dog, so a would-be amateur pirate would be solving a small problem by creating a much bigger one.
People have guns in rural areas everywhere. There are some exceptions like China where guns are very uncommon but if you are traveling through Eastern Europe, or Africa, or rural parts of south Asia you are going to encounter a lot of people who have guns.
There isn’t a gun culture like in the US in these places though, so you’ll have to know what to look for.
"gun culture" and people waving hand guns around for crime or "self defence" is, thankfully, limited to a small number of failed states, and the United States.
Also, the one subgroup of villages who do have guns are actual mafia members. But their power is mainly in organization and in having bought cops. You having own gun will in no way help you if you are targetted. The rest of people have them generally only if they need them for job, very rarely otherwise.
Villagers don't have guns for fun either all that much, it is also costly. The self defense laws are also such that gun is likely yo get you in serious trouble.
Granted, I did research on proxy gun rate estimators many years ago, using even older data, so it is possible that things have changed but I don't see why that would be the case.
Lots of people in the police or other security forces have access to guns. Often people who have done military service have an issued gun at home (eg Switzerland I think). Military service generally overlaps with a time in life when males are more vulnerable to suicide.
In most of the world, if you want to do a robbery, carrying a gun is not a sane option. You are more likely to end up in jail or dead or both.
Companies that provide armed security for cargo ships for example will keep the weapons on a boat at sea in international waters, transfer them to the cargo ship at the beginning of their security detail, then take them off with another boat before the cargo ship proceeds.
I also think some (almost certainly American) people underestimate how big an issue importing a firearm or possession of an unlicensed firearm can be in most of the world. It’s either many months of paperwork and almost guaranteed refusal, or risking many years in prison for an unlicensed firearm.