Hitting is never right.
I've seen children do it, even one of our grandchildren tried it on when they were about 6. Intially we were all too soft with him, es[ecially us the grandparents, but then we had to put our foot down. His dad agreed a contract with his, EG if the chidl did this or not do that, child would get less tv, treats, etc etc - it took a few weeks but it worked for us
It wont work for everyone but as a bystander watching our grandchild interact with his mum and dad, too often before the playing into hitting ad then playing - we all agreed clear cut lines between play and what is ot right
Another idea was "do you do it to your teacher." The answer is no, so why do to us
I thik many children go through these stages, but it is hard work and often a mother's heart as well of the grandparents is too soft but going along with it is not the right way
At times people need to seek outside help, advice but most children will stop
Btw, we also noted our grandkid got hyper after sugary treats - so his dad/mum us gave him a game of indoor footy or wrestling and then move onto something he wanted to do, bite to eat, tv, a bit of studying - we are all different but the sooner we act the better