I grew up watching Voyage to the Bottom of the Sea... those guys were always needing to break out the small arms. Apparently lots of rowdy sea critters looking to get in the boat.
BBC made a fascinating documentary called Perisher on the qualifying process for sub captains in the Royal Navy - it's available on YouTube (in the US at least)
https://www.youtube.com/watch?v=I1LF2I3fTbY
Of course, other aspects of other missions might also require firearms.
And since they have fucking nukes, all possible scales of violence are literally on the table.