In Hinduism, the concept of Karma is intertwined with the mythology of reincarnation. The tenet that our behavior plays into the quality of our future lives, and that our current conditions are predicated on how we've lived in past lives.
From that, the idea that how we live today, may reward or punish us tomorrow. Common to many religions, the idea that if we do something bad, we will be punished for it. We should be punished for it. In the absence of evidence for life being at all fair that way, maybe punishment will come in an afterlife, or in the next life, or maybe we just need to take it upon ourselves to start punishing each other, for whatever wrongs we've decided to call wrongs.
Originating amidst the culture of ancient India, Buddhism uses a lot of the same terminology, and tends to be commonly misunderstood to follow suit, but puts a very different spin on it all. Starting with the principal view of anatta - a complex subject that I'm going to gloss over this time, only mentioning it to reference how this inherently undermines the traditional idea of karma. If there is no-self, than what is it that's reborn, and how could this cosmic justice be meted out, if there is no-self to punish or reward? Not only how could it be, but really, should it be?
Alternately, karma refers to something intrinsically different. Not at all a system of justice or righteousness, something that isn't at all dependent on any sort of metaphysical belief system. It's just the idea that all behavior creates ripples of causality in our environment. This will not come back to bite us due to any sort of overarching system of fairness, but simply because this is the environment we live in. When we express hostility, we contribute to a culture of hostility. When we show kindness, we teach others kindness. Whether we pollute our environment, or help clean it up, we're going to be dealing with the consequences.
It is not a question of cosmic justice, so much as all-encompassing cause and effect. We are responsible for karma, just as it's responsible for us.