The submarine has two engines. There is a diesel engine which can only be used when the submarine is at the surface because it needs air (oxygen) to run.
Then, there is a second electric engine, and this engine can be used when the submarine is submerged.
I saw someone quote this article in this forum last week (also repeated in a lot of other articles)
http://www.dailymail.co.uk/news/article-5531645/Kim-Wall-possibly-gagged-death-trial-hears.html