Sounds like a tough time for him, and you too
firstly I think many many children go through a phase of hitting/aggression etc in itself nothing to worrying about and will pass.
But obviously you want a plan, what to do about it right now while waiting for it to pass!
What do you do now?
How has he picked up on ds being naughty so needs a smacking?
It seems to me like he is trying to engage in his world and is keen to make an impact and touch others. sometimes that's appropriate and gentle and then sometimes its too rough.
I'd persist in encouraging the appropriate bits by telling him that when he's hit someone they are hurt and oh dear, how can he make them feel better? his gentleness may come out a bit to stroke them better or whtever. Also I'd be pickking up on those times when he was appropriately toughing and telling him in descriptive terms - so hey you were so loving and gentle!
Obv sometimes removing to avoid injury is a must. At hese times I personally wouldn't punish so much as talk firmly but still cuddle him away and get him out of funk moment with love/distraction/calmness and then talk about how to basically apologise.
and yes fraid it it may not work instantly but think long term about how and what he is learning about the world.