In that case, the punishment is not a “wrong” because the person being punished has moral culpability due to their bad act.
That’s different from imposing a punishment on someone because of someone else’s bad act. That’s a principle that some societies hold that ours does not. In clan based societies, a wrong committed by one member of clan A to a member of clan B can justify retaliation against a different member of clan A.