How did my new iPhone know my WiFi credentials?
iCloud Keychain shares your WiFi networks, including passwords, to all of your devices. So if your new phone had been logged into iCloud, that’s where it got the network details.