Roughly speaking, it's a tool Youtube provide that's controlled by the copyright holders or their representatives.
From what I can gather, it does some sort of audio fingerprinting algorithm (similar to that used by "what's this song" type apps (Shazam, Google, etc.) and tests all new uploads to find approximate matches to the songs registered by those companies. If a match is found, the copyright holder's account settings determine what action should be taken. That might include taking the video down, or they could chose to add their own advertising to it (for which they receive the revenue).
All of this is totally automated.
It is, on one hand, a pain because the system can have false positives and other errors. It also doesn't allow for legally allowed use such as review, parody, etc. and some companies abuse these, and other, mechanisms (in particular some companies have taken down bad reviews of their products using these sorts of tools).
There's also been at least one case I know of where record company claimed ownership of some music that one of their artists had sampled, and took action against the original author/performer who had been sampled.
On the other hand, if it wasn't for these automated mechanisms, it's possible that there wouldn't be so much content published on Youtube in the first place.
Note that there is an appeal mechanism in place although, historically, it's not always been very good.
In this case, it might just be that the snippets of The Chain in Justin's second video weren't long enough to allow the algorithm to detect the song properly.
Cheers,
Keith