First of all, there are 2-way, 3-way, and 4-way switches; each with a different purpose. Two-way switches are most common and only have two terminals in addition to the ground screw. These are very simple in nature and simply either break or complete the circuit to turn a light on or off.
If you have two switches that control a light, you must use 3-way switches. Usually we see people get in trouble when they want to replace one switch with a dimmer. The dimmer in this situation must be a three way and the three wires must go to the correct terminals. (at the end of this article we explain how to look at a switch and most of the time get the hook-up correct. When all else fails, use a continuity tester.) Three-way switches will have 3 terminals in addition to the ground screw. One hot(usually black) wire either comes from the power panel into the switch or one hot wire exits the switch and goes to the light. In between the switches are two wires called travelers. These are considered switched hot wires and can be typically black, red, or sometimes a white wire has black tape wrapped around it at each end to designate it as a hot and not a neutral wire.
Let's take a look a some diagrams to understand how the circuit and switches work.
First here is an example of a 3-way switch setup. Light is off as there is no path for the hot.
Switch 1 Switch 2
---- ---- OFF
Hot / 2-------+2 -------
----1 1---- Light
3-------+3 / -------
---- ---- Neutral
--------------------------------
Switch 2 is moved, Light is ON as there is now a path for the hot.
Switch 1 Switch 2
---- ---- ON
Hot / 2-------+2 -------
----1 1----- Light
3-------+3 -------
---- ---- Neutral
--------------------------------
Either moving Switch 1 or Switch 2 will break the hot. And from the Off state, either Switch will make the connection.
The wires in-between the the 3-way switches are called travelers. If you are pulling wire through conduit, best to use different colored wire like blue and orange. If you are using Romex, I prefer to use the 4 wire version which has a ground, a white neutral, and a black and a red. Little more expensive but from a safety perspective I prefer not to wrap a black piece of tape around the white wire to mark it as a hot.
So use the red and the black for your travelers between switches. On the 3-way switches, you cannot just connect the hot to one of the terminals and the travelers to the remaining two. Look at a diagram on the switch or most times there is a single terminal on the top or bottom for the in/out hot and then two terminals (one on each side) at the other end are for the travelers. Connecting the hot to the side that has one terminal and the travelers to the side that has two terminals is usually NOT the way to do it.
If you didn't get the wires on the correct terminals, then you will find that it sometimes takes flipping both of the switches to get the light to turn on or off. With the proper wiring, any single switch that is flipped should cause the light to go on or off.
If you have more than two switches controlling a light, then you will also have 4-way switches in the circuit. We'll cover that in another article.
And please remember to turn the power off first. BZZZT sounds or arc welding your switch is not a good thing.