Providing an update.
As people here have suggested, I have tried rebooting the router. Changed from 2.4 GHZ and 5Ghz. Tried different wifi networks in different places. No difference. Same problem.
I today went to the Apple Store. I showed the problem to the Apple technician. He was very surprised this was happening. He had not seen customers presenting with this problem before now. He ran tests and could not find any hardware problem. So, it is most likely a (serious) big in the phone software.
He offered to replace the phone with a new one but I said there is no point as the same issue would be on the new phone as my partner has the same problem on a brand new iPhone Air.
I will reset the phone and set up from new rather than migrate from a backup to rule out a possibility of some sort of software corruption when doing a transfer from an old phone. This is very unlikely to solve the problem but worth a try.
IF the problem persists, I may replace the phone or return for a refund.
Very disappointed in Apple releasing phones with such a high price tag where the most basic of things do not work properly.
A lot more iphone 17 customers will show up at stores with this problem over the coming weeks. They just don't know they have this problem. But, they do have it.