I was staying in a hotel in London and using my Mac. There was hotel wifi which worked fine. However the Mac would (after waking from sleep) connect to a neighbouring EE WiFi network which was very weak and required logging into. So each time I would need to connect to the hotel wireless network.
I did a quick Google search and realised I could prioritise wireless networks, ensuring that the Mac would connect to the hotel network first, by reordering my networks, and ensuring that the hotel network was above the EE network.
The process is System Preferences -> Network -> Wi-Fi -> Advanced…
You can then Drag networks into the order you prefer.
This now means that my Mac will connect to the right hotel network.
Now this feature was removed in Ventura and Sonoma. If you are using the newer OS then you will need to turn off Auto-Join. You could also remove the problem network.