We are energy within a physical body, first and foremost.
This energy has the ability to leave the physical body, particularly at night when there is no physical resistance. As a non-physical entity, it can do far more than the physical body. it can fly, travel and do amazing and wonderful things. This is sometimes referred to as astral projection. The ability to project outside of your body. When you are outside of your body you can often look at yourself sleeping. There are many people who are now trying to control this experience by using astral projection and lucid dreaming techniques.
When you awaken, you can sometimes have memories of events that took place whilst you slept, which is why you knew that you were sleeping.