Karma does not punish. You punish yourself. If you commit some action that you end up having to be punished for by society, that is karma. Not the punishment, but the action and reaction. The cause and the effect. Also, punishment is not guaranteed. Your actions can disrupt the flow of karma that would not lead directly back to you, but to others.

Karma is not about what you do and why or what the consequences are. It is about what actions stem from the actions that came before them. You trip on a rock, you fall. You fall, you hit your head. You hit your head, you crack open you skull. You crack open your skull, you die. This is karma. Not you hit your head and died because you did something bad in your life. That is not karma.

Donald Trump deserves those billions of dollars, private jets, and to be in charge of a vast supply of the Earth's populous and resources ... because he is such a nice guy and all. No, he deserves it because his actions led up to that occurring. Karma does not take morality into account. The law of karma simply states that we are the products of our past actions and the past actions of those whose lives intersect ours. Causality.

What people usually refer to as karma in the West is actually what is called sanskara in Hinduism. It's the bad things we do that have real world consequences because of the rules involving cause and effect. Society set up a situation that if you commit a crime, you go to jail. Cause and effect. In this case, not natural, but social, but still just an example of cause and effect. Sanskaras are what happens to you when you ignore such cause and effect (karma).  

The ancient Vedics considered phenomena that was readily observable in nature and testable to be science, not religion. And although they could not prove with absolute certainty the law of causality at the time, science caught up and verified it later on.

Bhakti devotional texts later adopted karma from its philosophical origins into religion and integrated it with the concept of samsara. But this is later revisionist theology. It's kind of like how religion in the East claimed to be the origin of morality, but morals which have been show to have existed long before and outside of religious doctrine.

Karma has nothing to do with revenge, ethics, or justice. Karma is not a divine principle at all or a sentient one, and is often erroneously conflated with such concepts as kismet or destiny or fate. The actual law of karma (and causality) is quite simple to fallow: For every action, there is a result.

You can't put it more simpler than that.