Why does my light switch have three wires and a ground wire?

I am switching out a light switch and I found that it has three wires and a fourth if you count the ground wire. The really odd thing is, I replaced a switch and instead of turning the closet light on and off it is turning the room light on and off. Do you have any suggestions.
8 answers 8