How does the watch measure the altitude?

The altitude is measured via the pressure sensor.

The barometric pressure depends on the altitude. The smartwatch processor measures the barometric pressure and computes the actual altitude.
The pressure also depends on the weather conditions, this is why the altitude can change with the weather conditions. For this reason, the altitude must be calibrated from time to time.

When using the altimeter function, your smartwatch becomes a barometric altimeter, displaying the altitude relative to a global mean sea level.

The latter thus calculates the altitude as a function of absolute pressure (atmospheric).
As the altitude rises, pressure drops, and vice versa. The smartwatch's altimeter measures the difference between absolute pressure (atmospheric) and relative pressure (relative to sea level) to display the altitude.
You can calibrate your altimeter manually or use the auto-calibration option present.

NB: The smartwatch is aligned to QNH pressure setting.
In this instance, the pressure is ‘reduced’ to mean sea level, assuming ISA temperature profile from the station/airfield to MSL. An altimeter set to the airfield QNH reads the elevation of the airfield when on the ground.

Important Notice:
Due to the use of pressure to calculate the altitude, your smartwatch’s altimeter is sensitive to variations in atmospheric pressure, i.e. in weather changes.
It is therefore not uncommon to observe altitude differences of 100m in a night.
The value displayed may, therefore, vary without the altitude having actually changed.