how it works

This is not a good explanation.  I'm terrible at this; for every analogy I make, I want to explain why it is wrong.

The radar is a lot like the sonar in old submarine movies.  Instead of sound, the radar uses electromagnetic waves; the exact same thing as visible light or radio or wifi, just a different frequency.  The radar transmits EM waves, they go out into the world, "bounce off" the world, and come back.  Like an echo.

There is a condition to this.  For the EM wave to reflect back to the radar, instead of any arbitrary direction, it needs a surface with the right kind of regular, repeated spacing.  It turns out the ocean does a good job of this.