Youtube's audio detection is unbelievably powerful. Don't think for a minute that they haven't detected the songs, even if they've been slowed down or sped up, pitch changed, or even just using a small clip of the song.
Most songs are able to be used on Youtube as long as you don't monetize the video, you can check out the searchable database
here.
It's possible that they have purchased licenses for the music, although it would seem to me that it would be a massive pain in the ass to do and would probably offset any earnings from the video anyway so my guess is that they simply don't monetize the video and all is fine and dandy