The GitHub TOS is a license that is separate from the license in the code. It is legal and common for an author to license the same code multiple ways (and the licenses do not have to agree with each other). By agreeing to GitHub’s TOS and uploading code to GH servers, people are licensing GH to display the code, because the license agreement says so explicitly. This could be problematic if someone uploads code they don’t have the rights to upload, but then the violation is the uploader’s, and not GitHub’s.
Additionally, GH has a provision for already licensed code in section D.6:
“6. Contributions Under Repository License
“Whenever you add Content to a repository containing notice of a license, you license that Content under the same terms, and you agree that you have the right to license that Content under those terms. If you have a separate agreement to license that Content under different terms, such as a contributor license agreement, that agreement will supersede.
“Isn't this just how it works already? Yep. This is widely accepted as the norm in the open-source community; it's commonly referred to by the shorthand "inbound=outbound". We're just making it explicit.”
https://docs.github.com/en/github/site-policy/github-terms-o...
The use of licensed code in other projects must be done under the terms of that license or you aren't legally (under copyright law) allowed to use the code.