If you look at the human imagination, this neural circuitry can generate output that can defy the laws of nature, cause and effect and probability. We can use the imagination to fly to the moon, flapping our arms, while throwing dice all sevens a million times in a row. This departure from natural laws, allows humans to create all types of synthetic things in that matrix. We can get the answer before the solution, reversing cause and effect, so it looks like effect and cause. We may need the work the solution, later, so others can see cause and effect. A book is developed often out of sequence but will be published in logic order. Most people who just read but don't write will assume both form the same way.
That being said, the conscious mind is not the only part of the brain that uses the imagination. Often inspiration is a result of unconscious processing using the imagination. This is common in dreams. The conscious mind comes in after the unconscious processing in the matrix and might continue the train of thought. Dreams are not always cause and effect or probable, so the conscious mind may have to process it further to explain in terms of cause and effect.
There is a related affect of the mind called sensory expectation, which is often connected to the unconscious mind and imagination. Let me try to explain this with an example. Consider a woman who has the urge to go shopping. She feels the desire to go to her favorite store. However, there is no exact thing she consciously needs to buy. She will go through the racks and look at everything, until she sees that special item that catches her eye. The sensory expectation was already in her mind, but somewhat unconscious. The potential associated with the expectation was satisfied when the reality sensory input, which later enters her brain and overlaps the unconscious expectation. She may not be sure what her gut was telling her buy, based on what might be possible, but she will know when she see it.
This is no different from the artist, who sees the image of the final statue, within in the raw stone he begins with. That image may be somewhat fuzzy in his imagination, and even subject to change in the field. But as he cuts away the stone, what meets his sensory expectation will remain.
In the case of your dream, the unconscious is using the matrix of the imagination to jump to a conclusion in the future; effect before cause. This sets a potential in terms of sensory expectation. When you see that expectation within reality, you knew it, because it reduced the potential of the effect and cause, via cause and effect. Because sensory expectation can reverse cause and effect, into effect and cause, it doesn't always settle with the rational mind, until they collect their own data or have such an experience.
I remember having a dream when I was young, about a particular female I would eventually meet. When I met her years later, I remembered the dream since the potential of the induced sensory expectation had finally been met. It was like shopping and knowing what I needed or wanted when I saw her.
She may not have been the one, since the first time we slept together I had a dream of her being a witch with men in chains around her. My unconscious mind was projecting to what would be the nature of our relationship. She knew how to work men by anticipating and satisfying expectations until there were addicted. The dream kept me on guard, allowing me to outlast the others. In the end I gave in and cause and effect closed. You can avoid sensory expectation.