Theoretically, in the heat of the moment when the grandmother is telling the mother to stop, the mother needs to keep her cool. I suggest that she stop the action and say, simply, "I think we all need to cool down." That is the most graceful and safest response.
The biggest issue here is that when a child sees that the adults in his life don't agree about how to discipline him, that conflict can be a negative factor, potentially teaching him to learn how to manipulate the adults, or cause him to act out even more as a way to get their attention. Either way, this can make a child feel insecure and unhappy.
It's in the child's best interests for the adults to figure out how to prevent this from happening more. Theoretically, if the grandmother is inappropriate, it makes sense for the mother to sit down with her quietly and ask her not to intervene in front of the child because it undermines the mother's authority. Theoretically, if a grandmother intervenes in the heat of discipline, it would make me, as a mother, wonder why she felt the need to do that and if I needed some parent education or coaching.
So why am I saying, "Theoretically"? Because of all the things I don't know about your question. I'm especially troubled by the word "punishment." What do you mean by it? I prefer to see parents think about discipline, not punishment, because children are more likely to gain insight into their own behaviors from discipline, whereas from punishment, they tend to only learn how to not get caught the next time. Is the mother's punishment physical? Is the mother hurting the child? Does she do this frequently? Is the child afraid of her? Does the mother have an anger-control problem? If the punishment is not physical, is it verbally abusive? Does this happen frequently? Does the mother have a habit of over-reacting to the child's misbehavior? What was the child doing that warranted punishment in the first place?
And what about the grandmother? Does she have a habit of inappropriately injecting herself in the mother/child dynamic? Is she over-reacting? Is she worried for the child's safety? Is there an unhealthy dynamic between the mother and grandmother?