OK I'm not a ship guy here, but I'll chime. The prime movers in US diesel subs were Fairbanks Morse Opposed Piston engines, or Opies as we railheads call them. The basic layout has two crankshafts; one across the top and the other at the bottom of the engine. There is a cylinder (six in all) that has two pistons that are timed to move towards each other and apart, in one cylinder, one from the top and one from the bottom. A picture is worth 1000 words.
A more modern engine, but you get the idea. These had a limited success in railroad locomotives, one distinct disadvantage for that application is that they are very tall. Also, they are very smoky, as lubricant from the top half of the engine collects in the cylinder while shut down.
So what you saw in the engine room was the top- inverted- part of the engine. The bottom is below the deck.