Most of the time I have no recollection of my dreams, none at all, but one I had a couple of years ago is as clear now as it was then, to the point that I remember the minutests details of the dream, I even questioned some details about this dream during ithe dream. Most dreams I might remember something for a very short period, but never all of it, any thoughts why this particular dream has stuck with me and in such detail. I can,t see the relevance of the dream at all even after all this time?
Usually, when I remember a dream really clearly, it has to do with what I was dreaming about. It could be a situation relevant to one I am already dealing with. It could be because of whoever is in the dream with me. If it is someone I know well, I am more likely to remember the dream.
Most of the time, if I remember a dream vividly, it's because of how it made me feel. It could be nightmares that don't even sound scary when recounted aloud, but for whatever reason just cause some horrible sense of dread or fear. It could be something happy or something where I feel love or anger or anything like that. But it's usually the feeling itself that sticks out for me and makes me think of other details.
Dreams are complex in that it's your subconscious breaking down events from your everyday life and trying to handle them and process them. It breaks them into so many different pieces and metaphors that it's really hard to figure out what they mean.
I find that keeping a dream journal really helps out with this. If I write down a dream, what happened in it, how it made me feel, and then try to figure out why, I can usually figure out in what way it is relevant.
There could also be causes associated with magic. I know there are a lot of people who believe that spirits can contact people through dreams.
Astral projection deals with willful out-of-body experiences, so I doubt this would have happened to you accidentally, but that may be something to look into anyway. There are some very well-written and informative articles on this site covering those topics, if you would like to know more.