You are surrounded by a mass of metal, hundreds of electrical circuits and electrical motors. However, magnetic is not the only kind compass, only the one we most often think of. By the way, the movement of the sub through the water also generates magnetism.
It does! 
No physics stop working just because your underwater!