In previous macOS versions from Monterey and prior, there used to be a preferred network list that you could edit in the Network -> Wi-Fi -> Advanced screen. Since Ventura has done away with System Preferences in favor of System Settings that screen is no longer available. If both networks are in range at the same time, the list of preferred networks would determine which one would be chosen over the other.
If network A & B were already setup previously they are remembered. If you are trying to set it up now that you are on Ventura you can list the preferred networks and change the order via the command line in Terminal.
MacBook's will always assign the network interface en0 (zero) to the Wi-Fi device. Desktop Macs usually assign Wi-Fi to en1 instead. So issuing the following command below in Terminal will list the preferred wireless networks. The top most entry has precedence over the lower entries.
networksetup -listpreferredwirelessnetworks
Example results:
Preferred networks on en0:
Starbucks
McDonalds
James iPhone
Let's say you want McDonalds to be the preferred default because there's a Starbucks close by. Who knows, maybe you prefer the coffee at McDonalds (*wink*)? This is just an example...
Remove the McDonalds network first
networksetup -removepreferredwirelessnetwork en0 McDonalds
then add it back but with a higher index value (starts counting from 0, 1, 2, 3, etc)
networksetup -addpreferredwirelessnetworkatindex en0 McDonalds 0 WPA2
^ Index value is 0
^ WPA2 is most common Wi-Fi
Example results:
Preferred networks on en0:
McDonalds
Starbucks
James iPhone
These settings sync with your other Apple devices.