The most common way is through the use of inductance which is related to electromagnetism. When you pass a current through a wire a magnetic field is generated at right angles to the flow of current in the wire. If a metal object - such as a car - enters the magnetic field it acts like the core of a solenoid and changes the magnetic field and increass the inductance of the electric circuit. This change in inductance is used to send a signal to the trafficl light that a car is at the intersection. Then, depending on the logic systems of the light, it either stays green longer, or changes the light from red to green so the car can proceed instead of waiting for a timed light to change.
You will usually see this type of sensor as a series of lines cut into the surface of the road. Wires are put in these cuts, then sealed with a waterproof material and put into action.
it is simple the road has sensors that sense the presnce of a car some distance before it reaches the traffic light. The sensors could use many principles eg the magnetic theory stated below or it could be something more simple like a camera. the important thing is that it is able to count the number of cars that come by there and maybe even calculate its speed. the process after that is simply a system that estimates the time the car would take to the traffic light, the number of cars waiting for the light to change and many more. it then changes the light in favour of the road that most deserves the green light. i hope this was helpfull