Different apps and gadgets track sleep and sleep stage with different methods: sounds, movements and pulse analyses.
Sounds analysis detects snoring and sleep talking with a microphone. It also takes into account your movements (awakenings, body position changes) to determine the sleep stages.
Movement analysis uses accelerometer sensor. It takes into account the number and amplitude of your movements during sleep and determines the sleep stages. The more you move, the lower the quality of sleep and the worse is your sleep.
Heart rate analysis determines the sleep stages more accurately because heart rate increases when we go out of the deep sleep.