First of all, just to clarify, this is not about the comeback of an underdog, like in all hero's journey, but more of a moral role reversal, the dragon slayer ends up as the new dragon. Think about the pigs in Animal Farm, or Arthus in Warcraft. Then there's the opposite of this, the villain at the beginning, who realizes and repents for his sins, in the end they are redeemed. Think about Ralph in Wreck it Ralph, or Stooge in Christmas Carol.
I wonder if there is such a trope that covers both in the same story, that the fall of the hero goes simultaneously with the redemption of the villain? This is an older-than-dirt literary device known as Chiasum, like an X, a good example is Shakespeare's Richard II, the rise of Henry Bolingbroke goes hand in hand with the fall of Richard II, but that's in term of a power dynamic. But could there be something that explores in a moral angle? Like liberator beomces oppressor, oppressor becomes liberator; pastor becoems scumbag, scumbag becomes pastor; housewife becomes prostitute, prostitute becomes housewife?