i believe it uses a combination of both accelerometer data and heart rate data to judge how deep your sleep cycle is.
giving you an approximation of the time you are awake, sleeping lightly, or sleeping deeply.
notice no claim of REM sleep.
other companies / non-apple devices use only accelerometer data to try to give you the same info.
still other companies / non-apple devices use the same accelerometer data and heart rate data that is available to apple devices but these companies may claim to also judge REM sleep as well (Withings Activité).