The "Command Line Tools for Xcode" don't require an Apple ID to install (and provides a C/C++/Objective-C/Swift toolchain (LLVM/Clang) and things like Make and Git). Not to mention other compilers not provided by Apple that you can just download and install. And yes, while you do need an Apple ID to download Xcode from Apple, you don't need to be signed into macOS with it (you can download it from the Apple Developer site).
Nah. In one case no one prevents you from torrenting third party Xcode at your own risk. You can run any code you want on your device. But in the other case you can't even use the OS. Cope however you want but QED.
So nah, same.