This question already has an answer here:
What are the factors that determine the next birth? Between karma and last thoughts before death, which one is more relevant? King Bharat was so worried about his pet deer that he was re-born as a deer. This is confusing. Why King Bharat's accumulated karmas didn't come in aid? It means that the last thoughts too are equally important and perhaps score over karmas undertaken all through the life. Or is this just a story to teach people that too much attachment can lead to a downfall. Pls explain.