Oh boy. Look, I feed my cat, keep her healthy, keep her happy. She spends almost every spare minute by my side, whether she wants feeding or not. She follows me around the house constantly, sleeps on me, meows for me when she's in the other room and feeling lonely.
She also bites me or swipes at me occasionally. For starters, we have this game where I put my hand over her face and she gently gnaws the skin between my thumb and forefinger. But it's not always a game. Sometimes I'll be: stroking her, brushing her, just randomly putting my hand on her back, and any of one those can trigger a swipe or a bite.
Perfect example: this morning I gave her a kiss on the head goodbye before I headed out to work. She immediately gave a warning meow and swiped at me. I told her not to be so grumpy, situation done. She was instantly happy and purring again.
You know why she does these things? SHE'S A MOTHERFUCKING CAT. The ONLY way she can communicate "I've had enough" is by swiping her tail, flattening her ears, giving a warning "piss off" meow, swiping (with or without claws) or by biting. Cats have low patience. Cat's don't have the capacity to say "Oh, dear, would you mind ever so awfully maybe not stroking me?" They react instinctively. Does it mean they don't love you, don't appreciate you, don't want to be near you? NO IT BLOODY WELL DOESN'T. It means that, being a cat, they lost patience for a millisecond, reacted, and are now over it.
I had 3 cats growing up (now have 1, but have worked with rescue cats previously). When they used to swipe at me, I cried. Couldn't help it. Because I was a teenager. Now I've grown up and have the common sense to realise she's just being a cat. You're applying a human situation to a cat. This is not comparable to you sitting and quietly having a conversation with your DD, and her suddenly hauling off and smacking you one around the mouth. Cats are not the same as humans.
You really need to wrap your head around that. As the so-called more intelligent species, the onus is on you to learn to read a cat's body language, and teach your daughter accordingly. Yelling at the cat or punishing the cat won't make him stop because this stuff is instinctive for him.
For the record, when people come over and start stroking her head, I do say "Be careful, she likes to bite when you stroke her head". They get it, they're careful, they don't run screaming bloody murder out of my house. It's possible.