The App Store is the usual way to get a full macOS installer, but it only likes to hand you the newest one. When I want a specific version, for a bootable USB stick or a virtual machine, the terminal is quicker.
First see which installers Apple offers for your Mac:
softwareupdate --list-full-installers
Pick a version number from that list and download it:
softwareupdate --fetch-full-installer --full-installer-version <version>
Leave out --full-installer-version and you get the latest recommended installer. There is also --launch-installer, which opens the installer as soon as the download is done. I’d leave that off unless upgrading right away is really the plan.
The example I’d use it for: download the installer of the version you want, then turn a USB stick into a bootable installer with createinstallmedia, which I wrote about in an earlier tip. The download gives you the installer app that the createinstallmedia command lives in.
A few caveats. These installers are many gigabytes, so don’t start this on a hotel connection or a phone hotspot. The man page says the option exists since macOS Catalina, so a really old Mac won’t have it. And an installer for an older version only helps on a Mac that can still run that version; a new Mac with Apple silicon can’t go back to a release from before it came out. Read the list carefully before you download anything.
Further reading: softwareupdate man page (ss64), Create a bootable installer for macOS (Apple Support)