Itunes looks at your ID3 tags, if they match up with what other users have uploaded than Itunes makes a prediction. As more and more libraries are uploaded the predictions get better and better.
However this is not always the case, as songs that have been uploaded by a CD are still able to get "matched" Some speculate that it works by just the tempo of music that is matched with similar artists and genres.
Either way songs that are recognized are liked to a wealth of music.