Dogs are pack animals, when a top dog doesn't approve of another dog's actions, violence ensues and the dog learns that whatever they did wrong leads to violence and pain and thus avoids it.
Not to say it's the right thing to do, but, it's what some do and it works, however, this mostly applies to hunting dogs and sledge dogs.
For pets, it's really not necessary, dogs adore us as our overlording masters and just yelling at them and acting threatening will teach them right from wrong. There's no need for actual violence. Although, it's worth noting that dogs have almost no memory and must be punished or rewarded extremely promptly.