After falling asleep, the cerebral cortex is not completely suppressed, and various fantasy scenes appear in the mind, which is a normal physiological phenomenon of human beings.
You don't have to worry about having a strange dream that scares you. If you treat it as a unique experience, you will feel much better.
Generally speaking, some dreams are caused by the pressure of life, so in a sense, dreaming is also a form of releasing pressure.