The reason why you wake up just before your alarm clock goes off is because your body doesn’t like being interrupted. Waking up gradually is a natural part of the sleep cycle. Your body releases hormones to prepare for the stress of waking, and an alarm clock will interrupt that. So if you have a regular schedule, your body learns what time the alarm goes off, and begins the process of waking up earlier.