A lot of the time the owner of the video will credit the anime artists and the song owner in the description box or at the end of the video. That and as long as the music isn't being used for profit, YouTube will, in most cases, allow it to stay up.
It'd kinda be the same for like, a Relay for Life event. They play music and stuff owned by popular artists but no one steps in and says "Hey...thas illegal you're gonna have to turn that off."
I think as long as credit is given though, it's considered 'ok'.