This is the basic circuit for a three-way switch. The gray circle represents a light bulb controlled by the two switches. It is gray because it is "off." The two lines ending near the left side of the drawing go to a power source, like the circuit breaker panel in your house.
The green rectangles represent the switches. Notice that one conductor comes into each switch, but two go out. When the toggle is thrown the pathway inside the switch shifts from one of the out conductors to the other.
Here you can see that electricity can flow along the upper wire through the first switch, but its pathway is broken at the second switch and the light remains "off."
Step 1: The Light Comes "On"
Step 2: Turning the Light "Off" from another Switch
In my mind I like to think of three-way switches as like a construction zone on a four lane highway. If one set of lanes is closed, a crossover in the median moves traffic over to one of the lanes normally used for traffic going in the other direction. If there were no second crossover, traffic would stop. But, the second crossover brings traffic back to the original lanes and traffic continues to flow.
Step 3: The Light Comes "On" Again
When you encounter what was supposed to be a three-way circuit, and you can turn it "on" at one of the switches, but not at the other switch, unless the first switch is already "on," the problem is usually that one of the wires going into the switch is on a terminal for one of the two wires going out of the switch.
Not all three-way switches are the same, either. All of them have two screws on one side of the switch and one screw on the other side. But, the screws for the wires running between the switches may be on the same side of the switch, or they may be on opposite sides of the switch at the same end of the switch. You cannot make assumptions. It is not uncommon to find that one switch in a three-way circuit uses one arrangement, but the other is from a different manufacturer and uses a different pattern for the screws.
If you have a continuity tester, you can shut "off" the circuit breaker and test the switch to determine which screw connects to what.
I helped a friend at his vacation home. He had a three-way switch at the top and bottom of a stairway. Since the time the home was built thirty years ago he has had to turn the switch at the bottom of the stairway "on" first. Then he could turn the light "off" or "on" from the top of the stairway where the bedrooms are. If the switch at the bottom of the stairway was "off," he could not turn the light "on" from the top of the stairway. The problem was what I mentioned above. The wire going into one of the switches was on a screw terminal for one of the wires going between the switches. In this case, I did not have any meters or testers, but had to reason out the problem. I got it solved in about ten minutes. He is happy now because his three-way circuit works as it should.
See the second image. This is an update. I discovered an exception to the rule that three-way circuit problems are due to two wires transposed into each other's place. The photo shows a dimmer switch that can be used as a single-pole switch or as a three-way switch. These switches fail in time due to overheating. When they do, the switch may work when the toggle is up or down, but not in both positions. This can make you think two wires are in each other's place, but the switch simply needs to be replaced. A continuity tester does not work on one of these switches. If you find one on a three-way circuit that is not working, just replace the switch and your problems will likely be solved.
Step 4: Four-Way Switches
The graphic shows the pathways through two four-way switches. One represents the pathway when the toggle is up and one represents the pathway when the toggle is down. Think again about median crossovers on an Interstate highway. A four-way switch has the effect of reconnecting the two wires running between two thee-way switches. Four-way switches accomplish the same thing as if someone ran to one of the three-way switches and flipped it.
Step 5: A Four-Way Switch in the Circuit
Step 6: Turning the Light "Off"
Any number of four-way switches may be added between two three-way switches. Flipping any of the switches in the circuit will turn the light "on" if it is "off" and vice versa.