that question came up in a medical supplement in the Mirror (or similar newspaper) recently. From what I can remember of the answer it was to do with the stress caused to the body/brain when waking to an alarm so the defence mechanism is to wake just before it.
I once woke up at 5pm thinking it was 5am which was my usual time for getting up on an early shift but didn't realise after I'd come home at 2pm,sat on the sofa and the next thing I knew, it was 5.
Where did the time go?