Your car interrupts the flow of electricity and sends a signal to the light system to change. This is why motorcycles and bicycles sometimes won't change the light - not because of weight but rather because of their size that is not sufficient to interrupt the electrical loop.
Traffic lights commonly detect vehicles using digital sensors mounted on the lights themselves, or through an inductive loop embedded in the surface of the road. Both methods allow the traffic system to keep tabs on stopped vehicles occupying the intersection and help traffic to flow smoothly.