How does making merit affect karma? I believe I understand the basics of karma as the effects of our intentions and actions (good &amp; evil) which will play some role in this and future lives. But how does merit making affect karma? If a person has done something evil in the past can making merit improve one's karma? Is merit gained even for insincere actions such as when people do something good but are motivated by gaining reputation or status? Or is merit not a real thing but just a concept which functions to encourage people to do more good deeds so they'll have less time or inclination to do bad deeds?
Kamma is action which produces results, which could be called "merit." It's like seeds planted in a field, no one knows for sure when they will ripen, but if they were planted, they will ripen:


  Just as when seeds are not broken, not rotten, not damaged by wind &amp; heat, capable of sprouting, well-buried, planted in well-prepared soil, and the rain-god would offer good streams of rain.
  Those seeds would thus come to growth, increase, &amp; abundance.
  
  In the same way, any action performed with greed ... performed with aversion ... performed with delusion — born of delusion, caused by delusion, originating from delusion: wherever one's selfhood turns up, there that action will ripen.
  Where that action ripens, there one will experience its fruit, either in this very life that has arisen or further along in the sequence.
  
  AN 3.33


Insincere actions are those performed with greed or delusion. There's no "tricking" kamma; if you do a greedy action, the consequences are automatic, like how a person can't indulge in sensual pleasures without also becoming accustomed and attached to them in the process.

If evil has been done in the past, performing good actions now doesn't cause it to become unplanted, but developing good qualities of mind here and now means that when things ripen, you can lessen their effect.

For example, someone who meditates and keeps in mind the impermanence of all things will be less likely to be driven into rage and depression if a flood comes in and destroys their home, because this is a perfect example of that impermanence they keep reminding themselves of. They might even see the positive side that it re-affirms to them the principle of impermanence. If you don't develop good kamma right now by developing the mind, you're more likely to lose it when bad things happen.