according to all the folklore in most places, it's a demon/spirit that sits on your chest for different reasons.
but it's probably games of your mind, there is a scientific explanation somewhere but i can't remember where i read it, maybe in the same site there is one.
and you were definitely sleeping, when you sleep it takes time to understand it's a dream, but if you were awake you'd know about it. and why it happens only when you look up i don't know, but it might have something to do with it.
weird shit happen when you sleep, there were times that i couldn't open my eyes in the dream because the sun was hitting on me from the window, or you know you're dreaming and do whatever the fuck you want. i actually tried to fly once and after 2-3 times i did it those fuckers end soon though