Many people take piano lessons in hopes of being able to entertain folks with a song, perhaps a sing-a-long, maybe even take requests.
Key to that is being able to play by ear, to play, in full arrangement, any song you can hum. I can do that. Here's how I learned.
Ironically, it's because I can't read music well at all. You see, when you play from sheet music, it goes from your eyes to your fingers, no ears required. Your ear never develops.
Instead of learning a song by reading music, I started, by trial and error, trying to plunk out, with one finger, a tune I could hum: Chopsticks. That trial-and-error process developed my ear. Each note I played gave me feedback: "Whoops, that's not what that note should sound like" or "Yes, that's what it should sound like." After learning to plunk a very few songs, I developed a sense of how far up or down on the keyboard the next note should be.
When that got a little boring, I added one harmony note to the melody, again by trial and error. I induced how far away the note from the melody would likely make a nice harmony note.
I simply kept building on that, adding more notes to the harmony of those songs and adding new songs. That constantly developed my ear further until I was able to play any song I can hum in full arrangement. It really was as simple as that.
Here's me playing a few things, all by ear. I've never seen the sheet music for any of it..