
Ontological dignity and moral dignity aren't the same thing, when we commit serious offenses, we can lose moral dignity, but our ontological dignity remains.
To restore moral dignity, there must be justice. Justice can be a mercy for both the victim and the offender. Keep in mind that this is in regard to criminal offenses, not in relation to sin. In regard to sin, moral dignity is restored through the reception of God’s mercy.
So why does this distinction matter?
Today, however, there is an increasing awareness that the dignity of the person is not lost even after the commission of very serious crimes...CCC2267
This doesn't deny the justice needed to restore moral dignity, instead it acknowledges the ontological dignity of mankind was raised during the incarnation.
Dignitas Infinita 18 to 19
The Indelible Image of God
18. The first conviction, drawn from Revelation, holds that the dignity of the human person comes from the love of the Creator, who has imprinted the indelible features of his image on every person (cf. Gen. 1:26). The Creator calls each person to know him, to love him, and to live in a covenantal relationship with him, while calling the person also to live in fraternity, justice, and peace with all others. In this perspective, dignity refers not only to the soul but also to the person as an inseparable unity of body and soul. Accordingly, dignity is also inherent in each person’s body, which participates in its own way in being in imago Dei (in the image of God) and is also called to share in the soul’s glory in the divine beatitude.
Christ Elevates Human Dignity
19. The second conviction follows from the fact that the dignity of the human person was revealed in its fullness when the Father sent his Son, who assumed human existence to the full: “In the mystery of the Incarnation, the Son of God confirmed the dignity of the body and soul which constitute the human being.”[30] By uniting himself with every human being through his Incarnation, Jesus Christ confirmed that each person possesses an immeasurable dignity simply by belonging to the human community; moreover, he affirmed that this dignity can never be lost.[31] By proclaiming that the Kingdom of God belongs to the poor, the humble, the despised, and those who suffer in body and spirit; by healing all sorts of illnesses and infirmities, even the most dramatic ones, such as leprosy; by affirming that whatever is done to these individuals is also done to him because he is present in them: in all these ways, Jesus brought the great novelty of recognizing the dignity of every person, especially those who were considered “unworthy.” This new principle in human history—which emphasizes that individuals are even more “worthy” of our respect and love when they are weak, scorned, or suffering, even to the point of losing the human “figure”—has changed the face of the world. It has given life to institutions that take care of those who find themselves in disadvantaged conditions, such as abandoned infants, orphans, the elderly who are left without assistance, the mentally ill, people with incurable diseases or severe deformities, and those living on the streets.
