You say "How can both these theories be true when they contradict each other?"
They don't contradict each other. The reason they don't contradict each other, is because you spend some time in heaven or hell, before reincarnating back to earth. You spend some time in heaven or hell as a result of your good or bad deeds, and once they are exhausted, you return to earth.
Here is how various scriptures describe this process for both heaven and hell:
Heaven
Manusmriti 12.20:
If he practises virtue for the most part, and vice only in a small
degree, then, invested with those same material substances, he obtains
happiness in heaven.—(20)
Srimad Bhagavatam, Canto 11, Chapter 10:
Text 23: If on earth one performs sacrifices for the satisfaction of
the demigods, he goes to the heavenly planets, where, just like a
demigod, he enjoys all of the heavenly pleasures he has earned by his
performances.
Text 24: Having achieved the heavenly planets, the performer of
ritualistic sacrifices travels in a glowing airplane, which he obtains
as the result of his piety on earth. Being glorified by songs sung by
the Gandharvas and dressed in wonderfully charming clothes, he enjoys
life surrounded by heavenly goddesses.
Text 25: Accompanied by heavenly women, the enjoyer of the fruits of
sacrifice goes on pleasure rides in a wonderful airplane, which is
decorated with circles of tinkling bells and which flies wherever he
desires. Being relaxed, comfortable and happy in the heavenly pleasure
gardens, he does not consider that he is exhausting the fruits of his
piety and will soon fall down to the mortal world.
Text 26: Until his pious results are used up, the performer of
sacrifice enjoys life in the heavenly planets. When the pious results
are exhausted, however, he falls down from the pleasure gardens of
heaven, being moved against his desire by the force of eternal time.
So, what this means is that if you do a lot of good deeds, you experience great happiness in heaven, and then when most of the results of those good deeds are exhausted, you return to Earth, but in higher life forms like a rich man, or a holy man, etc.
Hell
Manusmriti 12.21:
If on the other hand he practises vice for the most part, and virtue
only in a small degree,—then, ...
he suffers the torments inflicted by Yama.—(21)
Manusmriti 12.16:
In the case of misbehaved persons, there is produced out of five
constituents, another strong body, for the suffering of torments,
after death.—(16)
What this means is that when very evil people die, they go to Naraka (Hell) and get a new body that is specifically created to experience and withstand tremendous torture.
After they have suffered, through this body, the torments inflicted by
yama, those constituents become dissolved into each of those same
material elements.—(17)
Once the Jiva has experienced the suffering in Hell with this body, the body is destroyed and he no longer experiences the suffering in Hell. What happens to him now? This verse specifically answers your question:
Manusmriti 12.52:
Persons who have committed the heinous offences, having passed, during
several years, through dreadful hells, reach, after the expiation
thereof, the following migratory states.—(54)
So after suffering in various hells, they are reborn as creatures on Earth or as other supernatural creatures like Rakshasas.
Another verse:
Yājñavalkya 3.206:
Having passed through most despised hells, by virtue of their grievous
sins, and thus having their had Karma exhausted, those who had
committed heinous offences become born again in the world.
And just like the case of heaven, most of the punishment is meted in heaven, but the residue is experienced on earth. A person returning to earth from hell is reborn as plants, insects, animals, low-caste, diseased, poor, etc. And finally when even the residue of the sins are exhausted, he is born into noble families.