Detectors. They detect when something goes through them and how long it takes to cross.
The light gate has a beam going from one LED/IR light source onto a detector. As something goes through it, the beam is "Cut".
The light gate measure how long the beam has been cut for. That gives you a measure for time.
Some light gates will allow you to plug in the length of the crossing object, and then it'd automatically calculate:
Length of object/time = How fast it was travelling.