The Law of Karma as most scriptures say is certain and no one can change what is Destined.
Why do we experience pleasure or pain? Once we know the cause, we could take appropriate action, either to overcome pain or prolong pleasure. The Law of Karma basically tells us that pain and pleasure are on account of prarabdha karma phalas-the fruit of past actions.
There are three kinds of karma. Sanchita or accumulated karma is the sum of all the total fruits, good and bad, obtained during past births. We may find a person who does not care for others and yet living a good life; the present situation that he seems to be enjoying could be for the good deeds done in his past life. If he is troubling his fellow beings in this life he is sure to live a miserable life in his future birth. This is how karma works.
Agami karmas arise from deeds that would be performed during the course of this lifetime by an individual, be it good or bad deeds or a mix of both. Remember that the rewards of this are added to the sanchita karma and therefore increase its volume.
There is a small story which emphasises that prarabdha karma is inevitable:
Once Lord Yama visits Sriman Narayana in Vaikuntha. At the entrance to his right he finds Garuda, the vehicle of the Lord who acknowledges him and to the left he sees a small sparrow. Looking at the sparrow Yama makes a surprised gesture and walks inside. The sparrow who sees Yama making a surprised gesture thinks that its time is up and Yama is going to take him away to Yamaloka and so it starts trembling in anticipation. Seeing this Garuda tells the sparrow not to worry and that he would help it. Garuda, who could fly at the speed of wind, asks the sparrow to sit on his back and he takes it to the far-off Gandhamadana Mountain near Rameshwaram. He then tells the sparrow not to worry as he would be safe there and gets back to the entrance of Vaikuntha.
After some time Yama comes out and finds the sparrow missing. Garuda, who was proud of what he had done, asks Yama what he was searching for. Yama enquires about the sparrow. Garuda tells him that the sparrow is now far away and safe. Then Yama asks Garuda to tell where he had taken the sparrow to. Garuda tells him he has left the sparrow on the Gandhamadana Mountain. Listening to this Yama is amazed at the intricate design Sriman Narayana has made and tells Garuda that when he came to Vaikuntha he was surprised and wondered how the small sparrow which was supposed to be killed by an eagle on Gandhamadana in a few minutes would reach there!
Such are the mysterious ways of karma finding ways to make one realise the fruit of action, past or present. Others might say it’s sheer coincidence!