This behavior though frustrating and embarrassing is not uncommon amongst toddlers. It’s a normal phase that most kids go through and is mostly an outlet for their frustration at being unable to express themselves when things don’t go the way they want.
This particular phase can start from anywhere between 14 months and above, but it usually manifests when the kid is exposed to other kids, so it could be at a social setting or childcare center. Even children who are more vocal than their age, can still experience frustrations as much as the others.
The worst thing you can do in this situation is overreact. Though there are different
opinions on spanking of children, in this situation however, spanking is not the best option and it will end up aggravating the situation. You can try giving the child a time-out for about two or so minutes where they’re forced to sit in one spot and behave themselves. This also helps the child to calm down. Do not speak to the child during the time-out, but when it is over, sit him/her down and explain the reason for the time-out and why such behaviors are not allowed.
Make sure you explain why such behaviors are not allowed and how they hurt others. You really can’t start asking toddlers how they’ll feel if they’re bitten by someone else because they don’t understand cause and effect, so they can’t really relate. But giving them a non-confrontational form of punishment makes them understand that their actions will not be tolerated and that there are consequences for acting out.
And if they repeat that particular action, you can give them another time-out. Depending on how old the child is, you can also teach them about apologies and explain why they need to make one. Introduce positive reinforcements when they apologize by praising them for the apology, which could come in any form from. It could be a kiss, or you could make them give something of theirs to the person they offended.