I found this in a Smart Circuits instruction manual. When clicking a button, the remote displays an invisible light. If pointed at the TV, the TV will detect it with a light sensor.
I think newer TVs use Bluetooth.
So the real question would be:
"How does BLUETOOTH work?"