A DPDT air conditioning relay should do the trick
House 2 is connected by default. When House 1 calls for water, it "takes over" and powers the well itself.
Air conditioning relays are rated at 30A and are rated to start motors. It's a 2-pole relay, and it switches both hots, but not ground. This setup must not use neutral: if it does, get a 3-pole DPDT relay, which will be rarer and more expensive. A relay normally connects its two Common terminals to its two NC terminals (Normally Closed, or connected when not energized). When energized, it disconnects NC and connects Common to the NO terminals (Normally Open, or connected when energized).
Each house has wires going to the well pump which are past the presure switch, i.e. They are energized only when that system is calling for water. Those are the wires we will be working with today.
The two wires from the pump are connected to the relay's Common terminals.
The pump wires from house 1 are connected to the relay's coil. That means when house 1 calls for water, the relay will snap over. The pump wires for house 1 also go to the NO (connected when energized) contacts on the relay.
The "common" wires on the relay go to the pump. That will connect house 1’s power to the pump.
The relay's NC (connected when not energized) contacts are connected to the pump wires from house 2. That means house 2 powers the pump whenever house 1 does not.
Note that NC and NO terminals never connect to each other. That is VERY important! For instance there is a scheme with simpler relays that is dead wrong and will short the two houses together. At best, it will trip the breakers. At worst, this will make both houses' meters spin rather faster than you want them to.
Normally in mains electrical, nobody cares about phasing because loads don't care. However in this case we may be switching "live" between two power supplies if both houses call for water. If we switch phases when we switch power supplies, it will cause the motor to jerk rather hard, and that could wear out the motor. The one at the bottom of the well.
We presume that the two houses are powered from reasonably close points on the power grid, that will be close to "in phase". This may not be possible: if they are on different transformers they may be irreparably out of phase, in which case you may need something more sophisticated.
The way you phase them is by running two different color wires (e.g. red and black) starting at the pressure switches. When able, have both houses call for water, and measure voltage between the two blacks. There should be near 0 volts between them. If there is near 240V between them, they are out of phase - swap red and black on one of the pressure switches and re-check. Later, if anybody has work done to their service panel, check phasing again.
From this point up to the relay, be careful to keep red and black matched.