Yes, I think it's because we're driven to try to learn something from our bad experiences, even if very often there is nothing to be learned. Our mind goes over a past experiences again and again and again hoping for a new insight that never comes or reexamines a frightening possibility in the hope that it can be avoided. It doesn't need to be an exact match for our mind to find it engaging; it just needs to tap into the same emotional threads.
Back when I had a lot of unresolved childhood trauma from abuse/neglect by the adults in my life, I used to be captivated by harrowing stories about abuses of power and sadism. Even though they understandably depressed me, I was drawn to them nonetheless.
This and other experiences in life suggest to me that seeking happiness is not actually a primary instinctual drive. The human mind seems much better suited to focus on negative rather than positive stimuli since it arguably aided survival in our dangerous evolutionary past. I see this phenomenon you're talking about as an extension of this instinct.
That's my theory anyway.