Generally, two types of Engines can be seen on any vessel;
The main Propulsion engine is generally a 2-stroke engine, which is the heart of any vessel, whose primary function is to generate thrust and to provide the necessary propelling power to move the vessel from one port to another.
Most modern ships use a reciprocating diesel engine as their prime mover, due to their operating simplicity, robustness, and fuel economy compared to most other prime mover mechanisms. In this type of Engines, the rotating crankshaft can be directly coupled to the propeller with the engines and it results in the Ship Propulsion.
A ship is like a floating city with all the privileges enjoyed by any normal city onshore. Just like a conventional city, the ship also requires all the basic amenities to sustain life on board; the main among them is power or electricity. And this power/electricity is generated through Auxiliary Engines/Generators on ships, which are generally 4-Stroke Engines. Sometimes these 4-Stroke Engines are also used to propel the ship (usually in a small size vessel).