Submarines don’t use active sonar; this would give their position away. They use passive sonar, which is just listening for the noises around it. You try walking through a room blindfolded, only by listening for the changes in ambient sound around you to detect objects. It is possible, but hard.