Active AF systems measure distance to the subject independently of the optical system, and subsequently adjust the optical system for correct focus.
There are various ways to measure distance, including ultrasonic sound waves and infrared light.