The fist submarines were propelled by their crew members. This limited the speed and distance they were able to travel. As technologies evolved, new propulsion systems were introduced and submarines became mechanized. The path of submarines are dictated by the propellers and the rudder, both of which are powered by an engine of some kind.
The propellers change the mechanical energy supplied by the engine into thrust. Thrust is a force that acts by changing the acceleration of the water over time and thus changing the momentum. The propellers push on the water with that force, and the water pushes on the propeller with the same force.
So where does the power for this thrust come from? Most modern submarines are powered by nuclear reactors. Some US Navy submarines use what is called a pressurized water reactor. In this type of reactor, nuclear reaction transfers high amounts of energy to water. The water is kept under high pressure to prevent boiling. This water is then piped into the steam generator, where its heat energy is absorbed through water-tight barriers, by more water. The two water reservoirs are kept separate so that the second water supply does not become radioactive. The water in the steam generator is not pressurized, therefore when it absorbs enough heat energy, it will boil. This steam turns the propulsion turbines. A portion of the energy created by the turbines goes to running the submarines propellers, while the rest is converted into electricity to be used throughout the ship.
image courtesy of www.nsua.edu
As you probably know, nuclear power is not without its risks. However, the nuclear reactor is surrounded by double barriers that protect sailors. On an average patrol underwater, sailors typically are exposed to less radiation than they would be if they stayed on the surface and worked in an office building.
At the end of their naval career, the ships must be defueled. This process takes place routinely throughout the lifetime of the ship as well. All material that have been exposed to radioactivity must be disposed of in the proper manner.