We only need to punish a dog when it bites. For example, we can make some kind of noise to scare it when it bites, or directly punish it with corporal punishment to make it feel the pain. Over time, they will have a bad impression of biting people, and they will not bite people again in the future.
Tip:
It is best to educate dogs from an early age. If the dog grows up and develops habits, it is usually difficult to correct them.