The official way to use copyrighted music on YouTube is through YouTube Studio > Audio library. The audio library includes free music and sound effects, some of which don't even require attribution.
When a content creator uploads a video to YouTube with music, an automated system called Content ID automatically matches the clip against an extensive database to see if the audio is permitted or ...