I’ve been playing for almost 15 years now. I didn’t know how to read music back then until my 3rd or 4th year, so I had to mostly learn to play by ear. In my experience over the years, I’ve gained this understanding of learning to play by ear:
-Some people will automatically be better at it than others. I was mediocre; definitely not another Mozart! But the more I did it, the better I got. I am in college now for music performance and can remember music much better. I can recognize the pitches and my hand flows more freely now than before because I have played a lot.
-Sometimes it takes training. There is a requirement of music majors to take music/aural skills in which you have to train your “inner ear.” In one exercise, we are given a melody and have to dictate it correctly for a grade. It’s scary at first because it’s so new, but with practice you become faster and more accurate.
I hope this helps a little bit. Don’t be discouraged by any bumps in the road. It’s a part of music that makes you a stronger player in the end.