Is there any way to set network preferences per Wi-Fi connection?
The locationchanger commandline tool allows changing the macOS Network Location setting according to Wi-Fi SSIDs.

Basically, after installing, you create Location settings in the Network preferences with the same name as the Wi-Fi SSIDs you connect to. The tool then changes the network location setting according to the connected Wi-Fi network SSID.
If no matched name is found, it falls back to the "Automatic" network location setting.

See https://github.com/eprev/locationchanger for download and usage instructions.

It even supports advanced features like running scripts when a specific Wi-Fi network is connected. Please see here for more info on that: https://ruimarinho.github.io/post/automating-network-location-switching-on-macos/