This situation is usually caused by you being too anxious or living too depressed. You are under a lot of pressure, maybe you don't feel it, but in fact you live very tired, so in your dream, your spirit can't relax, so you become a "ghost" in your dream, making your nerves nervous all the time. May also be too excited before going to bed, or thinking for too long, will affect the memory after sleeping.
I suggest you relax yourself a little more, do more exercise to release the pressure of life and keep a relaxed attitude. Listen to some light music or drink a glass of milk before going to bed every day, anyway, let your heart calm down, don't think too much, and solve the troubles during the day! In this way, I believe that your sleep quality will be improved, and "ghosts" will no longer haunt you.