It's absolutely nuts. I mean, it's nuts to use violence as punishment on anyone who completely relies on you for their well-being. But it's especially grotesque for toddlers who barely even have the ability to form sentences. What on earth could anyone think that could possibly achieve.
I guess it achieves compliance. The child is crying, “misbehaving”, etc, it achieves compliance through fear/shock. is that the relationship you want with a child? no, but in a certain sense it “works” and anyway it’s what your parents did to you.
But it’s a beautiful thing to break that chain.