Two way switch have to work in pairs. Above is a simple schematic diagram of how the wiring for a two way switch should be installed.
As mentioned, a two way switch has three terminals, as seen in the diagram, S1 and S2 represents the two switches. In S1 you will notice that the live wire goes to “COM” in the switch, then connected to “2”. In this case, the “1” terminal and the “2” terminal are the common terminals connected by two common wires to the common terminals of “S2.”
The diagram demonstrate a state where the light are now being switched OFF. Now for example, “S1” is installed at one end of the corridor and “S2” at the far end. When you enter the corridor, you will switch on the lights using “S1”. Inside the “S1″, the terminals are closed via”COM” and “2”. What happens when you toggle the switch is the copper strip connecting “COM” and “2” will be pushed to connect to “1”. That means “COM” and “1” now forms a closed circuit. Now look at the diagram again.
The live wire from the mains will now get connected to “1” in S2 where it is again connected to COM in S2. From there the current is passed on to the light, thus switching the light ON.
When you walk right to the end of the corridor and you want to switch OFF the light, the switch will toggle the terminal from “1” to”2″, breaking the circuit, thereby switching OFF the lights. The switch will stay that way for the whole duration until someone else switches the lights ON again at either end. When that happens the reverse order happens.
Electrical Technology explains the working concept of a 2 way switch very clearly in this video. Though it is referred to as a Three way switch, the theory is very much the same.