Since known networks will be joined automatically, when you power on Mac, it will reconnect to the previous Wi-Fi network it was connected to last time. To prevent your Mac from automatically connect to a Wi-Fi network, you can disable the “Automatically join this network” option in your network settings. Here is how to do it.
Click the Apple menu from the top menu bar, select System Preferences… > Network, under the Wi-Fi tab from the left pane, choose the Wi-Fi network from the Network Name box, uncheck the “Automatically join this network” option. Click the Apply button to save the change. After that your Mac won’t connect to this Wi-Fi network automatically in the future until you turn on this option manually.
Stop iPhone iPad from automatically connecting to a Wi-fi network
You can also tell your iPhone or iPad not to automatically join certain known Wi-Fi networks. Check out this guide to prevent iPhone connecting to a Wi-Fi network automatically.