(I will be covering other switches in the near future)
This is an example of a DPDT switch, i.e. a double-pole, double-throw switch. These are interesting because they are basically two individual and independent switches built into one package. Both are thrown at the exact same time as you flip the toggle.
One particular use-case for these in model railroading is their ability to flip the polarity of a DC (direct current) input. If you have a plain DC locomotive on a section of track, you can install one of these switches to switch the polarity of the voltage going to the track, thus making the motor in the locomotive stop and run in the other direction, and thus make the locomotive reverse instantly.
These switches come in two varieties, either ON-ON or ON-OFF-ON. The first one simply flips from one position to the other, like the on/off switch for the lights in your room. The second one has a center-off position, so as you flip the toggle, the first click is the center-off, and then you have to push it again to go to the other position. Some DC motors do not like (of have their life significant shortened) if they are instantly flipped from rotating in one direction to the other direction repeatedly. A center-off switch may be safer for those, as it gives the motor a short bit of time to recover from the instant-stop.
The diagram shown above is how you wire one of these types of DPDT switches for switching polarity, looking at it from the bottom where the connection lugs are. On the left side is the input voltage, whether that be from a transformer or battery. The two center lugs are to be connected to the output, i.e. the track or (indirectly) a motor. To get the polarity-flipping feature to work, you need to solder an individual wire from one of the input lugs to the diagonally-opposite unused lug. Then, solder another individual wire between the other input lug and the last remaining unused lug. That's it. Make sure that these individual wires don't touch each other and that all of the soldering is done cleanly with nothing touching anything it shouldn't. The way this "circuit" works is when the physical toggle lever is flipped to the right-hand side (in this diagram) internally it is making contact between the two input wires, thus making the center lugs' output be identical to the input polarity. When that toggle is physically switched to the left-hand side, the right-hand lugs are now connected to the center output lugs. Since those right-hand lugs are connected to the input lug in opposite polarity, the final output is the opposite polarity of what the input provides.
This photo shows an example circuit where the DPDT switch is used to throw the Circuitron Tortoise switch machine. The transformer is 3VDC, so it moves the Tortoise relatively slowly. The Tortoise itself is designed to be able to handle constant voltage being applied to it while it is in the stopped position. So, this installation can have the toggle switch mounted to the layout's facia and control the direction of a turnout.