I used to use hallucinogens in the past. Could this be the cause of the spontaneous astral projection I am experiencing? I ask this because I am sometimes really frightened by some of these experiences.
Yes, your past experience with drugs is indeed a contributing factor here. The use of drugs does make one much more susceptible to spontaneous astral projection. But there really is no need to be so frightened. What you are experiencing is the rational mind's interpretation of emotional forces that you would normally be aware of, simply AS emotions! But in astral projection you are detached from the physical body, hence the term "out of body experiences", meaning that your rational mind is now no longer "grounded" within the physical state of being experienced in normal awareness or normal sleep. The result is that it interprets the emotions experienced during sleep graphically as weird and wonderful symbols that can seem to be as real as life itself. But I repeat, it is NOT real, it only gives the ILLUSION of being real.
Unfortunately there is not much that can be done to stop spontaneous astral projection. The best thing to do is to try to just relax into the experience. It is always terrifying at first, but once you have overcome your fear of dying, or being attacked, or being pulled out of your body, or anything similar to this, you will find yourself either standing next to your physical body, or else hovering above it. I can assure you that it is very frightening at first because the normal reaction is always, "My God! Am I dead?" But once again, just relax into this state of being. Once you are calm again, simply WILL yourself back into your body, or else just WILL yourself to lie down on top of your body and feel yourself sink back into your physical body. After that you will wake up, but then go back to sleep in a normal way.
As I said, once spontaneous astral projection has come about, it cannot really be stopped. It can only be controlled.