A gasoline/diesel engine will just seize up when exposed to water, and if it's on fire it will be extinguished. Same for electric motors.
Batteries however? No bueno. Both the Americans [1] and Russians [2] lost submarines to battery fires. Batteries are hard and marine environments are among the nastiest you can get with corrosive saltwater and mist everywhere and continuous extreme mechanical shock events from waves and storms.
This is also why I believe that it's a fools errand to waste any non-fossil fuel (no matter if "sustainable" production from grains, frying oil or similar, or synth-fuels) on heating homes like it has been proposed in Germany or driving cars with it. The stuff is far too valuable, we'll need it for a long time to power aviation and maritime navigation until we get batteries both high-capacity and safe enough for these cases.
[1] https://en.wikipedia.org/wiki/USS_Bonefish_(SS-582)
[2]https://www.theguardian.com/world/2019/jul/23/russia-submers...