iPhone has a tendency to connect to WiFi Networks that you had previously joined. However, you can disable this behavior and stop iPhone from Automatically connecting to WiFi Networks.
Stop iPhone from Automatically Connecting to WiFi Networks
When you connect iPhone to any WiFi Network, it automatically stores Network Name, WiFi Network Password and other details in its memory.
The next time you happen to be within range of this Network, your iPhone will immediately recognize this Network and will be able to automatically to this known WiFi Network, using login information stored in its memory.
While this default setting on iPhone helps in connecting to known WiFi Networks (Home, Office, Library), without the need to remember and enter Network Password, it can sometimes lead to security and network related issues.
Since, there is no global option in iOS to prevent iPhone from automatically joining known WiFi Networks, the only way to prevent your iPhone from joining known WiFi Networks is to Reset Network Settings on your device.
Another option is to manually select each known WiFi Network and Switch OFF the Auto-join option or totally forget the Network.
Prevent iPhone from Automatically Connecting to Public WiFi Networks
As mentioned above, the only way to prevent iPhone from connecting to all known WiFi Networks is to Reset Network Settings on your device.
Go to Settings > General > Transfer or Reset iPhone > Reset > select Reset Network Settings option.
When prompted, enter the Lock Screen Passcode > on the confirmation pop-up, select the Reset option to confirm.
Stop iPhone from Automatically Connecting to Specific WiFi Network
As mentioned above, the other option is to manually select each Known WiFi Network and prevent iPhone from connecting to this Network.
Go to Settings > WiFi and tap on the “i” icon next to the Network that you want to stop your device from connecting automatically.
On the next screen, move the toggle next to Auto-Join to OFF position.
After this Setting, your iPhone won’t be able to automatically join this particular WiFi Network.
If required, you can always connect manually to this Network by going to Settings > WiFi and selecting the Network that you want to join.