This ability has a formal name, "self-awakening", that you can use for a web search. The short answer is, nobody yet fully understands how this works.
This is a common ability among people and has been the subject of scientific investigation. Here is an abstract for a formal paper about it:
http://cat.inist.fr/?aModele=afficheN&cpsidt=2648736
This paper has been cited by 14 others more recently, which this search on the Google Scholar site summarizes:
http://scholar.google.com/scholar?hl=en&lr=&q=related:PsLaUEBjfnoJ:scholar.google.com/&um=1&ie=UTF-8&sa=X&ei=G1xETPCVO4KCsQP__OmiDA&ved=0CBUQzwIwAA
You'd have to purchase many of these articles to read them fully, but here's
another research summary that's free:
http://findarticles.com/p/articles/mi_m1355/is_n3_v92/ai_19491810/
I hope this gives you a good starting point to research further!
Cheers,
Jim