Basically, the Torpedo Officer stands there ready to shoot anyone who breaches protocol in some way.
Was it normal for certain officers to carry guns on nuclear subs? Can you fire a gun on a submarine? And why does this guy get to stand behind the captain with a loaded pistol? Who watches him?
Is this all just Hollywood ballyhoo?
This is only a partial answer, but, automatic rifles and pistols were carried on Soviet submarines and were peripherally involved in the actual K-19 incident. According to Captain Zateyev's account given in the non-fiction companion book to the K-19 movie, he was worried about potential mutiny after the radiation incident and ordered the collection and throwing overboard of all but five firearms on board, distributed to his senior officers. Elsewhere, he claimed to have contemplated suicide by gunshot during the disaster.
Does a sub have to worry about boarding?
I wanted to know more about the keys. Anyone got more info on the protocol for that?
Was it normal for certain officers to carry guns on nuclear subs?
No, but as /u/EvanHarper mentioned, K-19 had a small arms locker. The captain and the other officers would have to be extremely worried about security aboard his boat for anyone to begin carrying weapons. In the Cuban Missile Crisis, a Foxtrot class diesel attack submarine nearly launched a nuclear torpedo at the American ships that were hounding it, but the XO, Vasili Arkhipov (the inspiration for Liam Neeson's character in the movie), convinced the other two men to surface and ask for instructions from Moscow (the captain, executive officer and political officer all have to agree to launch a nuclear weapon). Nowhere does Arkhipov mention the presence of weapons of any kind during the incident, so it's safe to assume that even in the most intense situations regarding nuclear weapons release, small arms were not used.
The movie is exaggerated in many ways (the meltdown of the reactor would not cause any sort of nuclear explosion, much less a thermonuclear one) and this is no exception. It was just a device in the script to raise the tension.
Can you fire a gun on a submarine?
You can fire most guns at the pressure hull and the damage would be minimal. Makarov pistols and AK-47s, like they had on K-19, don't have enough energy to penetrate the inch or so of high-strength steel used in early Soviet submarines. The pressure hull could probably be breached by a large caliber armor-piercing round, but I doubt these would be allowed on the submarine, for obvious reasons.
The bigger danger of firing a gun on a submarine is that you hit a relatively delicate component (like a control panel or sonar screen) and potentially hamper the effectiveness of the ship. I suppose in the most extreme case, you could destroy the all instruments and controls in the reactor compartment, which could end very badly. Even still, there are redundancies and these submarines are designed to withstand a heavy beating from enemy torpedoes and depth charges.
Edit: added a few words
Allegedly, UK crews don't have two (or two-man, 4-key) systems. It's just one key on the boat that controls the launches. Is there a reason they haven't updated to two-person switches?