Modern variable-displacement compressors do not switch on and off. Instead, they use a control valve to adjust how much refrigerant they pump. Located in the back of the compressor body, this valve senses pressure changes in the suction and discharge lines. It changes the angle of a swash plate inside the pump, altering the piston stroke length. If you set the cabin temp low, it increases the stroke for maximum cooling. When the cabin reaches temp, it decreases the stroke to save energy.
These valves fail frequently due to debris or solenoid burnout. When they stick, the A/C will only blow cold at highway speeds or stop cooling entirely when idling. Mechanics often find that swapping this inexpensive valve fixes the cooling issue, avoiding the need to buy a costly new compressor assembly.