Switches can be duel use. With a switch on each side of the carrage pointing at the end plates for the gantry. Switches are wired is series normally closed. One switch is configured as the homing switch and as X limit switch either X+ or X- depending on where you want the X axis to home. The other switch is configured as just a limit switch for the direction opposite the homing direction. The wiring comes from the X pin on the controller through one switch to the other switch and then back to ground.
You do the same thing for the Y axis with 2 switches You can put one on each end of a Y axis rail and have the gantry activate them. Again 1 switch is configured as a homing switch and a limit switch in the direction you want the machine to home the Y axis in. Again the other switch is for the opposite direction. And again wired from the Y axis pin on the controller to one switch and then to the other switch and then back to ground.
The Z axis generally only gets 1 switch that is configured as home at the top of the Z travel and as Z+ limit. wired from the Z pin on the controller to the switch and back to ground.
You then go into you control software and tell it what pin numbers are for X,Y and Z and what direction for homing or referencing the axis.
When you start you control sofware up it does not know where the carrage is at in the machine world. Homing the 3 axis then informs the software where machine 0,0,0 is and then the homing goes to sleep.
Now if you move an axis and trip a switch by moving to far. The software will stop movement and not move again until you reset and move off the switch. When a limit switch is tripped Homing is lost and the machine has to be homed again.
Generally speaking the Z axis does not have a negative limit switch because by the time the Z axis hits the switch it generally will of destroyed the tool already.
All total you only need 5 switches. 2 X axis 2 Y axis and 1 Z axis.
Hope this helps
Dave