Equalizing unequal grounds with batteries
Voltages do not have a "universal" reference frame. A voltage is also known as a "potential difference", meaning that a voltage is just the difference between two points. So they can reference to any other voltage.

Engineers can work on a 400,000V cable if they don't connect to ground; indeed they are sometimes in a cage hanging from the overhead cable, which was put there by helicopter.

So when you connect a 10V battery to a ground point, it says, "okay, I'm now at 10V relative to this ground", and you disconnect it and then connect it to some other ground point, it says, "now I'm 10V relative to this ground" and so on. It has forgotten the first ground. The battery cannot remember the old voltage reference, indeed it never "knew" it, it just carries on generating the same potential difference relative to whatever one of its terminals happens to be connected to. You can take the same battery, charge it to +10 on its positive terminal relative to ground, then disconnect it, connect the positive terminal to ground, and the other one is now -10.

Which is a bit like magic, but it's really just boring old physics.