The principle of "the recompense is of the same nature as the deed"—does it happen to a person in this world and the Hereafter, or only in the Hereafter?
No, this means that the recompense is of the same nature as the deed, meaning that most of the time, the recompense is of the same kind.
Sometimes the punishment is that Allah punishes a person in the same way as his deed, as Allah the Blessed and Exalted said.
When the disbeliever said, "My Lord, why have You raised me blind while I used to see?" He said, "Thus Our signs came to you and you forgot them, and thus today."
You are forgotten, like retribution for example—the recompense is of the same nature as the deed. So whoever transgresses against you, transgress against him in the same way he transgressed against you. Just as Nuh ﷺ said: "If you mock us, we will mock you."
Just as you mock, so yes, but a person may not be afflicted with recompense of the same nature as his deed in this world, but he may be punished for it.
In the Hereafter, it is not necessary that he receives it in this world.