Here is a scientific analysis of how dreams work. It's under Question VII of Part I: "Whether Witches can Sway the Minds of Men to Love or Hatred." Among other methods, witches work to sway opinion while the person sleeps:
The apparitions that come in dreams to sleepers proceed from the ideas retained in the repository of their mind, through a natural local motion caused by the flow of blood to the first and inmost seat of their faculties of perception; and we speak of an intrinsic local motion in the head and the cells of the brain.
And this can also happen through a similar local motion created by devils. Also such things happen not only to the sleeping, but even to those who are awake.
See, we are influenced by the scientific-sounding description of blood through the cells... and then the friars slide in the reference to devils. It is hard to argue with such authoritative-sounding facts. And unhappily, few medieval folks did.
. . .