As long as you don't run Gentoo or any other distro that require you to compile your own packages, you can install the Firefox from repos and you'll have the same result.
I really suggest you to use yours distro package manager to install Firefox and use KeePassXC as flatpak, cause this way you'll have your apps updated.
Your solution, despite works, you'll have to update the packages by hand
However be aware that Ubuntu force you to install Firefox Snap even if you run apt install firefox
, so you'll face the same issue. For this reason I suggest you to move away from Ubuntu