Why, when you're dreaming you don't know you're dreaming?
Because that’s what it means to dream. To dream means to imagine and forget that it’s just imagination. The forgetting part is very important, that’s what makes it appear real, that’s what creates a temporary dream reality. All dreams are temporary, they must be, because you can neither forget reality forever, nor imagine a non-existing reality forever. Reality is very stubborn.
If not for the forgetting part, we wouldn’t call it “dreaming”. We’d call it “imagining” or “fantasizing”. Forgetting makes all the difference - when you fantasize, you may still enjoy it, but on some level you are always aware that it’s just a fantasy. When you dream, you’re not aware.
This awareness also gives you some level of control over the direction of your fantasy, which is quite obvious when you fantasize during waking hours, but people who practice lucid dreaming also exercise some level of control over their dreamscape even though it’s much more immersive. You can say that since the dreamscape is created by the mind, when you dream non-lucidly, you also ultimately have control, but it’s unconscious - the dream character doesn’t have control. It is precisely the forgetting which provides the illusion of having no control over your dreams.
Since dreaming is forgetfulness, waking up is thus remembering. If you suddenly remember during a dream that it’s a dream, you will either begin dreaming lucidly, wake up, or the dream will dissolve and you’ll experience what has been called “sleep paralysis”. You will experience yourself as consciousness with no bodily awareness. Since you are very unfamiliar with that state, it might get very scary. You might want to move, but you won’t be able to move, the body is relaxed and sleeping, only the mind is aware. Since you’re not used to being aware without being able to move your body, it may feel very “wrong”, and so often times a lot of fear comes with it, a panic. If it ever happens to you, don’t worry! Nothing wrong is going on, it’s just a moment of gaining awareness during sleep.
So it depends on the level of remembering. In total remembering, total awareness, dreams cease. If you are on the spiritual path and/or practicing meditation, it is normal to begin experiencing it periodically. As you get used to it, you will actually find that this state is very peaceful, very relaxing. Enlightened people experience it every time they sleep.
It is even possible to remember quite suddenly that you’re dreaming, open your eyes, and still without being able to move your body, see some hallucinations overlayed on top of your surroundings. When dreams dissolve, it is natural to experience a lot of fear. The more sudden the remembering is, the more fear you will probably experience, and the more disorienting it might be. But it’s not dangerous.