If you look at the photographs of old submarines, especially during the Second World War, you can replace that they sometimes have guns, which are clearly not controlled from the inside. In addition, it is not entirely clear why a submarine moving under water and firing torpedoes needs such weapons.
To begin with, the first submarines could spend very little time under water. As a rule, the submersion was carried out only before a combat collision with a large, dangerous ship, the only way to defeat which was to carry out a torpedo attack. Under water, the submarine consumed a huge amount of fuel, and therefore the "march" was carried out exclusively on the surface.
The idea to install additional weapons on the submarine was first realized back in 1910. This was necessary primarily due to the fact that there were not so many torpedoes on board the submarine. As a result, it was not very rational to carry out torpedo attacks on small and poorly protected enemy ships. That is why it was decided to put guns, with which the crew could knock out enemy transports from the surface. It was also used to fire at coastal ground targets.
In addition, the submarine needed at least some additional weapons in case it, in principle, could not submerge. This often happened in situations where the flight ran out of fuel or the submarine was damaged in one of the previous battles and could not safely go under water.
Note: with the development of aviation, anti-aircraft guns, primarily heavy machine guns, began to be installed on submarines.
Want to know even more interesting things? Then read about why Soviet submarines during the Great Patriotic War did not become a "weapon of victory".