VO2 Max is measured while you run on a threadmill or ride on a stationary bicycle at increasing intensities while wearing a face mask, which allows for the direct measurement oxygen in inhaled and exhaled air, in controlled conditions. Generally the volume of oxygen that you consume during this testing plateaus even though your work increases, and this plateau or VO2 peak is assumed to be your VO2 Max.
Cardio Fitness on the Apple Watch is an estimation of your VO2 Max based on measuring your heart rate response to a known aerobic effort. The Apple Watch will generate a VO2 Max estimate value after doing an outdoor running, walking or hiking workout or activity on relatively flat ground, with good heart rate and GPS data, and that equals or exceed a certain intensity.
The Apple Watch generate VO2 Max estimate values based on data from multiple sensors including the optical heart rate sensor, GPS, accelerometer, gyroscope, and barometer, as well as data from user inputs like age, gender, weight, and the use or not of certain medications that affect maximal heart rate.