In the books it is explained as past genetic memories taking over the person and overwhelming them. Not all past genetic memories were from good people. Paul had this problem and aligned himself with a benign ancestor. In "Children Of Dune", Alia was overwhelmed by her grandfather, "the floating fatman", and had to be killed to prevent him from starting new wars and conquest in her body.
The Baron being Lady Jessica's father was essentially an event through regular rape and abuse of his power. Or maybe the Bene Gesserit sisterhood "arranged" it like for Feyd to keep the bloodline.
I also find the karmic-reincarnational lines of these people to be quite intriguing also, along with the genetic lines, since the 6-book science "fiction" series by Frank Herbert is basically a true story, in which many of us lived in the distant future parts of the Milky Way's Spiral Time Streams, before we migrated to Earth and began reincarnating on this planet.
It seems like the two science fiction writers, Frank Herbert and L. Ron Hubbard were trying to stimulate our subconscious awareness of extraterrestrial past lifetimes into conscious awareness. Their own character seems to be depicted as Duke Leto Atreides in the beginning of Dune, reincarnated as Miles Teg, near the end of the 6-book series.
Duke Leto's son, Paul Atreides, seems to be reincarnated as Maneo, in the middle of Dune and as Mile Teg's daughter, Darwi Odrade, a leader of the Bene Gesserits, near the end of Dune. And Paul Atreides' son, the Dune Emperor, the worm-man, seems to be reincarnated as the other female Bene Gesserit leader near the end of Dune, Taraza.
I find it interesting also that the names of those two Bene Gesserit leaders, near the end of Dune, Taraza and Darwi, correspond rather closely with the names of Tarzan, Lord of the Jungle and Dar, the Beast Master, in Earth literature. One could extrapolate from the genetic and karmic-reincarnational lines in the Dune story into Earth history and legend, but that's sensitive data.