The simple answer is that a child’s dream could be the result of molestation, or it could be a consequence of hearing or overhearing about sex from someone and trying to make sense of it. Often people’s dreams are a reflection of the unconscious mind trying to understand something. You may have been sorting out the natural confusion of any child on first learning something about sex.
On the other hand, something seriously wrong may have happened. Your mother may have been trying to help you understand how to protect yourself without being explicit about it. It may have been the best she could do at the time.
It’s completely understandable that this has been a cause of anxiety and distress. I think you owe it to yourself to learn more. Please consider seeing a therapist who can hear your entire story and who can give you the validation you seek. Therapy can help you resolve your questions and the upsetting feelings that go with them.
I wish you well.