It could be there is or once was a three way switch in play. The white wire is the neutral and all other colors are hot.

Swap Out Those Old Crappy 3 Way Light Switches For Good Cnet
Red white black wires light switch. Well cover the easier scenario first. All home electrical wires made in the us. Attach the black wire coming from the light to the top right nut on the switch. In existing 3 way wiring this wire toggles hot between two switches. The hot wire from the breaker usually black neutral. Knowing which wire does what and goes where is imperative not only in the correct configuration of an electrical system but also for your familys safety.
Follow standard color codes that identify each wires function in a circuit. Electricians often use black red or blue wires to deliver electricity to a circuit from the main panel. Twist the two white wires together and attach a wire nut. They may use other colors for. Attach the red wire coming from the light to the top left nut on the switch. The wire that will be hot when the circuit is completed to your light usually black traveler.
Or it could be the red wire is the wire going to the fixture and the black wires are the live wires. The cable has a black wire which connects directly to the circuit and a red wire which connects to the switch. The ground wire also connects to the switch but the white wire gets spliced to the circuit neutral wire and bypasses the switch. When you see a red wire in a light switch box it can mean two things. The return wire for circuits usually white load. The standard way to power a split tab outlet is to run a three conductor cable to a wall switch.