The flatpak command on Ubuntu is used to install packaged software such as QGIS from a remote flathub repository. Normally, the following Terminal command to install QGIS is as follows:
$ flatpak install qgis
By default, this will install the stable branch of QGIS. In the screen shot below, it is version 3.18, but this may not be the version you want. Perhaps you wanted to use the long term release version, which is under a different lts branch.
To get flatpak to install the lts branch of QGIS, type in the following command in the Terminal.
$ flatpak install org.qgis.qgis//lts
And follow the prompts to complete the installation.