How do Wi-Fi networks persist between installs? I've just done a reinstall from the recovery partition and have found that all the previously known Wi-Fi networks have persisted, even though I formatted the main partition during the reinstall.

How are they still here?
They are synchronised over iCloud, so if you log in to iCloud the list of networks and their associated passwords are added to macOS.