There are two way, three way, and four way switches and they all require different wiring techniques. The type of switch is dictated by the number of wires attached to it. Two wires for two way, three wires for three way, and four wires for four way. Two way switches control a single light from one location and are fairly simple to wire. Three way switches control a single light from two locations and are a bit more tricky. And four way switches control a single light from three locations - and are the most complex to wire.
Before doing any work, make sure the electricity is turned off at the circuit breaker or fuse panel.
When removing the wall plate and exposing the switch, you'll know immediately what type of switch you are dealing with. It's important to replace failed switches with the same type of switch and that all of the wires be attached to the same location on the replacement switch.
Three way switches have a special terminal - it's marked with a black screw and the word common on the back. Locate the common wire on the existing switch and attach it to the common terminal on the new switch first. Then reattach the other two wires.
Now four way switches have two pairs of wires and it's important that one pair be reattached on the top and the other pair be reattached on the bottom set of terminals. Never split pairs between a top and bottom terminal. Once the switch is safely installed and the cover plate attached, replace the fuse or move the circuit breaker back to the "on" position.