M.P.
Hitting and slapping comes naturally and doesn't have to be modeled for a toddler to do it. In fact it's a normal developmental stage. Hitting/slapping is a primitive way of expressing ones self. He hasn't learned other ways to express how he feels. As you said, he didn't want to be hugged and kissed so much and slapping was his way of saying so. Your husband responded appropriately by backing off and waiting more for his son to initiate the contact.
Your MIL needs to also back off. Your son has legitimate feelings and is making the request by shoving her away. When she insists, she gets slapped. You might ask her how she would feel if she pushed someone away and that person got in her face anyway. Perhaps she can then understand how her grandson feels. Have you suggested to her that she will get more voluntary and thus more satisfactory hugs from her grandson if she does allow him to chose when to give them?
She can spend time with him without getting into his face. I understand the urge to hug and kiss often. I've felt that way at times too. The mature thing to do tho is to control yourself for the benefit of the other person. That is a part of loving someone too. In my opinion listening to and acknowledging someone else's needs is a more important way of showing love.
Would your mil understand better and accept not hugging if your son were to say, "no kiss." If so, you could teach him to say that.
As to when he slaps others, I'd gently grab his hands and say, "no slapping" each time that he has been the initiator of the hug or kiss. When he slaps when someone is trying to hug him and he doesn't want to be hugged, I'd gently take his hands and say I'm sorry. I didn't realize you didn't want a hug." Talk with him about how it's important to not slap someone but to use his words to say no kiss or even to gently push the other person away. It's OK too for him to squirm out of their reach. You just want to be sure that he understands that slapping and hitting is not acceptable while acknowledging his feelings and thus the reason for the slap.
Teaching not to hit and slap are important. Equally important is teaching respect for ones own body space.