The letters stand for 'Rapid Eye Movement'. People's eyes 'flutter' when they are dreaming and, consequently, 'REM sleep' is that level/depth of sleep at which dreaming is going on.
REM sleep occurs several times during a night as we sleep in cycles of different types of sleep.
If you wake naturally (ie not with an alarm) then you will have just have come out of a period of REM sleep. As this is the time when you dream, this explains why you can often remember your dreams on waking