Recent signalling systems allow to make that fully automatic.
With older hardware, the switch is always under the control of the driver.
He will first encounter a panel that tells him to drop the pantograph. If he doesn't, his pantograph will short the active catenary to the neutral section that separate both voltages, and cause the substation to fail.
Then, with all pantographs down, he will have to select a new position on his "administration" rotary switch. This selects the network (like SNCF) and the voltage (like 25 kV 50 Hz). A panel on the ground is usually placed to indicate where this action must take place. This action will select which pantograph to use and configure the loco internal circuitry for the correct voltage. It does not select which security system to use, however, because the electric and signalling transitions are not necessarily located at the same place.
And finally he will encounter yet another board that will instruct him to raise the pantograph. A detection device will check that the voltage present matches his selection and completely switch off the loco if not.
All pantographs are usually connected together, so that in case one fails, another one can be used, usually with severe restrictions, and provided of course that it is geometrically compatible with the catenary. The choice of equipment to be used inside the loco is done by its internal circuitry, I.e. big relays and switches.
Here is an example of a voltage change zone, between belgian 3 kV DC and French 25 kV AC. We are in Quevy, right under the neutral zone, looking towards France. Trains reaching that point already have their DC panto down, must now select "SNCF 25 kV", and wait for the "panto up" sign to appear before restoring power.

Picture from
https://www.foudurail.org/belge/quevy.html
And here is a picture of the driving post f a belgian HLE 16 quadri-voltage loco, with, at the right of the rheostat controls, the administration rotary switch.
