I like guns and believe I have a right to own one, but many governments don't, increasingly my own. The fact remains that it's a dangerous world, there are however, other ways to discourage/disable/kill a person besides shooting them with a gun.
I've not given this a lot of thought, but perhaps someone should; there must be hundreds of items that would not be out of place on a boat that most police would consider innocuous but could be used effectively to defend yourself in a fight.
I guess the most basic is your brain, as in common sense, but avoidance is not always possible.
There are limitations,of course. If a band of 20 men with AK-47’s storm your boat probable nothing less than seal team 6 will help, but a pair of thugs with knives or a single gun between them is a different story.
Awareness, planning, practice.