When I was quite young and still learning to play the piano I remember watching someone listen to a song on the radio and then quickly walk over to the piano and play what was on the radio. It was very impressive. I remember thinking how amazing that was. The thing that I've learned since then is that if you spend time with music, listening to it, playing it, paying attention to it, that things start to stick out. By this I mean certain chords start to become familiar, certain melodies that then go along with those chords. Probably the most important aspect of this is that chord progressions that start to stick out. These are the fundamental parts to playing by ear.
One thing that happens quite often with piano is that when someone starts their piano education they are usually taught how to read music first, then to play off sheet music. So when it comes time to play something that isn't written down they have great trouble. I know, this was how it was for me in the beginning.
To really learn to play music by ear you need to have at least some knowledge about chords and chord progressions. Once you know a little more about chords (major and minor and what they sound like) you can start learning to play by ear. The first thing to do is find a song you really like and would like to play. The second thing is to do is make sure it's an easy song. (You will probably find out pretty quickly how difficult it is to play!) If there are a lot of chord changes then it might be a good idea to pick another song. The thing about learning by ear, when you first start out, is that it will take a while and you will need to be patient. When I first started it took me quite some time and I had to work through quite a lot of frustrating moments but it's much more rewarding.
Some people will be able to pick up music by ear much easier than others. This is just a fact of life. Some people's ears are just more tuned to music than others. Quite often though, these people are the ones who listen to the most music.
The key is to experiment with playing along with music and give yourself time to learn to play by ear. You will find that the more you that, the better at it you will become, and after a while it will come naturally and you will be able to play with whatever is on the radio.