Using tracks from Apple Music in iMovie project
It seems like I would keep that as it is exported as separate file.


Yes, once you export from the iMovie project, you'll retain the audio tracks.




  What if these videos have been uploaded to Youtube?


You'll most likely end up with an automated Content ID claim. If you used a substantial portion of a copyrighted material in your video verbatim, your uploaded media may automatically get deleted from YouTube.

However, in most cases it is generally not troublesome if you have created some original content. Quoting from the linked article:


  Am I in trouble?
  
  Probably not. In most cases, getting a Content ID claim isn’t a bad thing for your YouTube channel. It just means, “Hey, we found some content in your video that’s owned by someone else.”
  
  It’s up to the copyright owners to decide whether or not others can reuse their original material. In many cases, copyright owners allow their content to be used in YouTube videos in exchange for having ads run on those videos. These ads may play before the video or during it (if the video is longer than 10 minutes).