Your phone is designed for Wi-Fi to connect to the best combination of signal strength, speed, interference rejection and other things Apple won't tell us about.
Exactly what that "combination" might be is not known, but the phone will always tend to favor signal strength over speed, and faster speeds are quite often weaker signals.
So, for example if the phone sees a stronger signal at 2.4 GHz than 5 GHz or 6 GHz, it will connect to 2.4 GHz.
The only way that I can get my iPhones to reliably connect to 5 GHz (I don't have a 6 GHz router) is assign a different name to the 5 GHz signal and then "aim" the phone at that network name.
Then, the phone connects to 5 GHz consistently, even though the signal at 2.4 GHz might be stronger with lower noise.
Frankly, I have given up trying to find the perfect connection, and have set my router to use the same wireless network name for both the 2.4 GHz and 5 GHz bands. I don't really care which band is connected as long as the phone provides good performance.