Why is Xcode 12.2 as large as macOS Big Sur?
Xcode 12.2 unpacked is 16.8 GB, 13.2 GB of which are platform operating systems.

iPhoneOS.platform is 5.9 GB
AppleTVOS.platform is 3.6 GB
WatchOS.platform is 3.3 GB

In comparison, MacOSX.platform is only ~300 MB since most of the platform is already available in a normal installation of macOS. Xcode doesn't just build apps for macOS — it also builds apps for other operating systems and runs a simulator of each OS.