The most direct answer comes from the Noam Elimelekh (Devarim, Ki Teitzei:4), who explains that a righteous person who engages in Torah study for its own sake and generates novel interpretations effectively creates new heavens — and since the original decree was issued against worlds that no longer exist, it is automatically annulled.
Mesillat Yesharim (Chapter 5) approaches the matter from the opposite angle: Torah study is the one remedy the Creator provided against the affliction of sin, and one who imagines escaping punishment without it is simply mistaken, dying in his sin — implying that Torah study genuinely intervenes in the causal chain between sin and consequence.
Derashot HaRan (10:5) adds a structural point: divine punishment always falls short of what the sin strictly deserves, and God — like a father — withholds punishment entirely once He sees the sinner has genuinely turned away, suggesting that any spiritual act that effects genuine change can forestall punishment.
At the same time, the Mishneh Torah, Repentance 3:1–4 frames punishment as following from a ledger of merits and sins, which implies that Torah learning would prevent punishment not by canceling a decree directly but by tipping the scales of merit — the mechanism is accounting, not annulment.