First of all in order to Undergo Karma there has to be a medium, example you can not see without eyes, So it means in order to undergo karma there has to be the medium of physical Body
Hell and Heaven are in your chitt(mind), not somewhere else on other planet.
Some atma has to come back even from Moksha to undergo some Karma.
The entire process of how karma works can never be known to humans.
All we know is by performing good karmas, one is practicing the purity of mind, because only a pure mind can become peaceful.
What we should learn from this Question is if something bad happens to us, show gratitude and ask god to give us strength to undergo this result of negative Karma.
Now the question arises should we pray only in bad times? No we should pray daily because Lord Krishna says in Gita "one perform karma every moment, even if one is sitting idle" and by repeating a prayer(thought) over and over again our intellect will become sharp and pure, which leads to pure and controlled mind, and in the end a state of tranquility can be attained.