There’s a phenomenon known as traumatic bonding, in which an abused child or spouse bonds to their abuser even more strongly than they would in a health relationship. It’s usually attributed to intermittent reinforcement.
I have an alternative explanation. My cat currently has a retinal tear, which means his life consists of pain, a mysterious cone around his neck that blocks his vision and hinders his movement, and waking up several times a day to the being he loves most in the world, his sole source of food and protection pinning him down and stabbing his eyeball (antibacterial eye drops). Three times in one week this being has put him in a tiny cage and takes him to a place where they torture him even more (fluorescent staining at the vet). He used to love head rubs, now he flinches every time I touch the top of his head, because he associates it with eye drops. He is displaying every symptom of human depression an animal is capable of.
The thing is, I’m inflicting all this on him because I love him. I am trying to save his eye, and I have absolutely no way to explain that to him. And it got me thinking: lots of parenting is like this. Even once the kids are technically old enough to understand English (a feat Nemo looks increasingly unlikely to to master), there’s lots of things you have to do for their long term good that they really hate in the short term. Some of these things they will eventually understand and be grateful for, some they will always hate. Either way, no human would ever survive to adulthood if they rejected their parents every time they did something that, from the child’s perspective, looks like torture.
So maybe we’ve evolved to have the capacity to love someone even if they hurt us, because we can’t tell good hurt from bad. Traumatic bonding could arise either straight from that, or from a perversion of that system, the same way chronic clinical depression arises out of useful emotions.