You've correctly diagnosed & confirmed that the fuel pump corresponds to the switch setting. Now you need to confirm that the GAUGE corresponds.

I can't say how it would have happened, but it seems that when the front tank pump is selected, the rear tank LEVEL SENDER is connected to the gauge, & vice versa.
There's a known issue of fuel returning to the wrong tank causing it to overflow, but that's totally different from your symptom.