It's both natural and learned. As MajorCharles says ^, you have to learn the notes and their placement before you can read or play the music. Once you've done that, you develop a feeling for what the music will sound like when you play it. But some people also have a natural talent called perfect pitch. Once they've learned how to read music, they can hear it in their heads just by looking at it on the page. That's something that can't be learned; it's a gift, and you need to be born with it.