Technically you can install XCode (older version) on macOS Catalina depending on your goals. If you are a developer wanting to have your app on the App Store, then you will want to have the latest version of XCode which will require a newer version of macOS (I'm not sure of the details since I am not a developer). Check Apple's rules for what is required for developing apps for Apple products and/or the App Store.
Develop - Apple Developer
Distribute - Apple Developer
Does your Mac even meet the system requirements for macOS 12.x Monterey? You can find the exact model of your Mac by clicking the Apple menu and selecting "About This Mac".
macOS Monterey is compatible with these computers - Apple Support
This article also lists which versions of macOS are compatible with various Apple hardware:
https://eshop.macsales.com/guides/Mac_OS_X_Compatibility
If your Mac meets the system requirements for macOS 12.x Monterey, then you should just be able to launch the Software Update System Preferences to download & install Monterey.
Update macOS on Mac - Apple Support
If your Mac is not compatible with macOS 12.x Monterey, but is compatible with macOS 11.x Big Sur, then you can access the various macOS installers (such as Big Sur) from the links in this Apple article which also includes optional instructions for creating a bootable macOS USB installer:
How to create a bootable installer for macOS - Apple Support
Make sure to have a good backup before attempting to upgrade macOS just in case something goes wrong during the upgrade.
You should always have frequent and regular backups of your computer and all external media (including the cloud) which contains important & unique data.