Just by listening to music, we can learn a lot about its structures and conventions. For example, even you have no musical training, you can tell that something is wrong with this scale (it’s followed by a proper C-major scale):
But we learn a lot more than just standard scales when we listen to music. When you’re exposed to a particular type of music for many years, you learn much more. Consider the following sequence of chords:

Anyone who’s been raised listening to Western music should recognize this sequence as an appropriate musical phrase (if you don’t read music, don’t worry — I’ll play it for you in a moment).
But change just one of the chords, and now something seems “off.” You might not be able to identify the third chord in this sequence as a Neapolitan, but you’ll know that doesn’t sound right when you hear it:

Even worse is when the final chord is changed, as in this sequence:

Now listen to this clip where all three sequences in a row are played:
See?
But surely we aren’t born with such sophisticated musical knowledge. When, exactly, is it acquired? A team led by Stefan Koelsh had adults listen to dozens chord sequences like these and monitored their electric brain responses. They found a different response when Neapolitan chords were played compared to the expected, in-key chord.
In a new study, they tested 5- and 9-year-olds using the same apparatus. The children were told to press a button when the chords were played by instruments other than a piano (this occurred about 8 percent of the time). The researchers weren’t interested in the other instruments; this was just to make sure the kids were listening. They analyzed the rest of the data and found the following results:
This graph shows the electrical response of a 5-year-old while the final chord was played. The dotted line is the response when the chord was in key, and the solid line is the response to a Neapolitan chord. The two arrows show where the response is different, starting at around 200 milliseconds after the onset of the chord. Both 5- and 9-year-olds show responses similar to those of adults. However, if the third chord was changed, as in the second sequence played above, the results were different:
Now there is no difference between the in-key chord and the Neapolitan. This differed from the previous results with adults, who, even with no musical training, showed a similar (though smaller) response to a Neapolitan in the third position. Even 9-year-olds show the same results as 5-year-olds. So though children as young as 5 clearly have a sophisticated cognitive mechanism for understanding music, as late as 9, they still haven’t developed a complete adult understanding of music.
Koelsch et al. note that language development follows a similar pattern: up to the age of 9, children can learn languages rapidly and recover quickly from disorders such as aphasia. After 9 years, both processes become more difficult. The team argues that this is evidence for a common system for processing both language and music.
Update: Since we’re seeing different accounts about whether people can hear what’s “wrong” with the clip, I created a poll to find out what portion of our readers can hear the Neapolitans. The poll refers to the second clip above (the chords, not the scales).
Koelsch, S., Grossmann, T., Gunter, T.C., Hahne, A., Schröger, & Friederici, A.D. (2003). Children processing music: Electric brain responses reveal musical competence and gender differences. Journal of Cognitive Neuroscience, 15(5), 683-693.