Karma is a very very complicated idea, one that has been articulated in several religions. It's explicitly from Hinduism, but the term and ideas thereof are found in Buddhism, Jainism and elements of it are even found in Christianity. But remember that religions themselves are but fingers pointing to a moon, with a goal of making you look skywards - people attempting to articulate greater truths that don't easily find themselves adaptable to the tools we have to communicate ideas.
One of the things that people mock about Christianity, for example, is the apparent contradiction in the New Testament in terms of the importance of works. To summarize, in one part, the Bible claims you are not saved by works, and in another, that your works are ultimately what condemn you. Another is Paul's suggestion that "nothing is forbidden" and yet he tries to rein in his followers in Corinth by suggesting certain types of people will be condemned based on their actions. But what the Bible tries very very hard to get at is, in my view, an elaboration of the nature of karma - which, in the eyes of some, seem like a contradiction in terms.
An illustration from the Egyptian religion is relevant here: a fascinating image of judgment in the afterlife - a heart being weighed on a scale against a feather, with a voracious monster ready to devour the soul possessing that heart if it is in any way heavier than that feather. Even the ancients understood, maybe we always have - that it isn't so much the effects of the deeds of the world, but the effects of the deeds on you which matter. And this is where karma comes in.
"Karma", or "kamma", is Sanskrit for "action" but also "effect", showing that the two are intertwined. That is all.
Unfortunately we in the Western world try to use Western ideas of "merits" and "demerits" to understand it, thinking of karma as some kind of objective "good boy points" and "bad boy points", that when tallied provide a "score" giving you your objective worth. Worse still, we'll even qualify "karma" - saying "good karma" and "bad karma", as if karma has a quality, or the two types can "balance each other out".
The general gist of karma is that your actions are evidence of your motivation, for certain - but worse still, actions feed back into your consciousness. Not only is your conduct a mirror of your personality, but your personality will eventually come to mirror that of your actions. If you look at someone as evil and deeply disturbed as Ted Bundy - he spoke to researchers before he died and claimed, in part that the reasons people like him eventually get caught is that they start out their careers highly attuned to the impact of their crimes and fearful enough of something to cover up or otherwise hide the tracks of their actions, but after repeated murders or rapes it just becomes yet another Tuesday - something normalized. Even if their intent all along was to be callous enough to do wrong, they go from being fearful of the consequences of the evil of their actions, to completely indifferent to it. Likewise, doing acts of kindness and mindfulness feed back into who you are and make you a kinder and more mindful person. Meditation can affect your brain and even potentially your DNA.
The long and the short of it is, doing the right kinds of things makes you better, and making you better fixes the world around you, even though it's transitory, a shade, something you pass through and have to give up. The Buddha explicitly stressed that the world was something to move from, but Jesus himself also taught you to hate everything including your own life, and likened the Kingdom of God to a man who sold everything he had to find a buried treasure in a field.
And here we start to get more in to the nature of why you're supposed to do these things. Karma is not a system to be "gamed". You don't "cover" a sin or "right" a wrong by doing some meritorious act to counteract or "pay for" a bad one. Like a child weighing up the pain of a spanking versus the pleasure of a transgression and happily bending over a parent's knee believing himself to have come out somehow ahead in the tradeoff. Or a bookkeeper or accountant doing a "tally" of good vs evil and deciding, like the medieval church did, to levy compensatory penances for crimes, believing it to cancel it out. There is no prayer or prescribed rote act that will somehow wipe the slate clean because of the mere performing of the act. You cannot achieve "salvation" by "works". There is, however, in unattachment, in repentance, in charity, in happiness, and in self-sacrifice a freeing of the soul. Something in the process of the surrender or the benevolence or the sympathy that sets you on a different path. And every religion tries to convey that message, one way or the other.
If karma, in the sense of "upvotes" and "downvotes" were the case, nobody would ever fear doing evil. Murder someone, but then go ahead and give to a hospital. Steal from tens of thousands in a ponzi scheme, but then write a check to a charity. The ledger would balance, and the angry powers that mete out vengeance would be satisfied and spare you the punishment of your deeds.
But the truth of the matter is, God isn't a vengeful monster with a law book, and there are no fates writing out your good deeds on one side and your evil ones on the other. But there does seem to be the idea that during your lifespan and at the end of your lifespan, the weight of your actions and the psychology of your actions will be what determines how you proceed. Good is its own reward, evil pays you back with interest. You can avoid the police, but you cannot escape the stain or the light that your motivations have granted you.
Sanskrit's a clever language. Cause is effect, effect is cause. So be mindful of what you do, even if you feel that there's never going to be any effect on anyone.