Unfortunately, it doesn't do that. For reasons that Apple has never explained, the Mac App Store only has the versions that require later versions on MacOS when you search for them, or click the download from the store. Currently the Pages on the MAS requires Big Sur or Monterey. I can't install it on my Mac mini running Mojave.
However, if they were once purchased/installed from the MAS, you should be able to download the apps from the Purchased section (click your account icon to access the Purchased tab.). That will tell you that your Mac version is not high enough for the current version but will offer to download the latest compatible version.