> The only legal way you can use copyrighted code is due to the license attached to it by the copyright holder.
This is wrong on so many levels.
1. Copyright grants a limited set of rights to the copyright holder. "Use" typically doesn't fall into that set. Everyone has the right to "use" copyrighted material for any purpose that isn't some kind of copy or distribution.
2. Even when we consider uses which are actually covered by copyright, a license is not the only way to legally copy the material. Fair use exists.
3. There is no such thing as "the license attached to it". Licenses do not "attach" to copyrighted works. A license is an individual agreement between the copyright holder and each and every person who wants to use the material (within the scope of copyright rights and outside of fair use). Those agreements can be different in every instance, if the licensor and licensee have so agreed.
The only thing a LICENSE file or other similar way of indicating a license on code does is make a (binding) offer to license the work under the specified terms to all comers. Once anyone actually has a license by any means, including a separately negotiated license, then the LICENSE file no longer has anything to do with them or their use of the material. In the case of github, they have separately negotiated (by making a binding offer of their own in their ToS) a license to use the material for the provision of their service; therefore the LICENSE file has nothing to do with them (unless they want to use the offered license instead of the one they negotiated, and they haven't negotiated away the right to use the license offered in the LICENSE file).