Aren’t there maps?
Sonar systems have not mapped the entire sea floor, and as others have pointed out, sonar is the main effective way to create such a map.
It's worth pointing out that regular, non-military ships do run into uncharted seamounts too. A good example is the discovery of the Muirfield Seamount, which happened when a ship in what charts said was water over 5000 meters deep ran into it. The top was only 16-18 meters below the surface.