Why and how did South Park use music from Eureka seveN?
Most likely in the same way companies like Crunchyroll buy licenses to stream anime. TV shows, etc. can buy licenses to use music made by other people.

https://en.wikipedia.org/wiki/Music_licensing