Lots of reasons, most of which overlap. They all revolve around the fact that surface ships make so much noise that they can't hear...well...stuff. There's a word more commonly used there. Anyway...
A ship moving on the surface is an endless splashing of waves against the hull, either from the water moving or the ship running into the water. They are also a constant roaring of foam; which is bubbles that are always popping. Little tiny bubbles make little tiny pops, but a zillion little bubbles popping at the same time, all the time...not a little tiny noise. It's like flying over a forest listening for deer...in a helicopter. They ain't gonna hear nothin' but themselves, period. Now,
@IglooDude was a surface ship submarine hunter and may claim that it isn't
that bad, I dunno.
A submarine survives by being quiet. They don't have to 'quiet down' just to listen, because they are
always being quiet. Every aspect of designing and building a submarine factors in being quiet. So if the only way to find something is by hearing it, you want to listen from a submarine.
That's the first thing. Now, consider having to kill this thing. Everybody has weapons with ranges in miles, maybe tens of miles, maybe even a hundred miles. That includes the submarine. The problem is that the submarine has a pretty good idea where surface ships are even before they are in range of the longest ranged weapons. They can track, and close in, and track some more, and plot and chart movement and calculate, and do it some more. If a surface ship starts coming towards them they can evade it while it is still far enough away that it doesn't know the submarine is anywhere around, because the submarine not only knows it is there, it is tracking its movements. If we're in a large room and I'm blindfolded and just groping around trying to find you, how hard is it going to be to stay out of my reach, really? You see me coming clear across the room and just get out of the way. If you want to kill something
you can't let it see you coming. The only thing a submarine doesn't see coming is a submarine or a derelict.
Ultimately, the only thing a submarine fears is a better submarine.