Here is a brief pictorial explanation of how the rail switches work.
Switch beforeSwitch after