Our son was doing this a lot at daycare to older kids. Daycare gave lots of comfort to the one in pain and less attention to the one doing the hitting. He seemed to be doing it for attention- not aggression, and her strategy worked well-she didn't feed into the negative attention. Also, because it wasn't out of aggression, we taught him to hug others more and we read him social stories and watched videos about "not hitting" daily with him.
Just distraction. Whenever she starts doing it, take her elsewhere and show her something else. My son is doing the same thing to our new kitten. And it is the same as you described it. They see it as something they get our reaction to every time they do it, and it amuses them. The only thing that works for us is to distract him... And I'm hoping it's just a phase and it will pass soon 🙏🙏🤞