As children of God, even if we commit a mortal sin, and ourselves reject God; He remains a loving Father, and sends graces that we can use to restore our relatioship with Him. While we have cut ourselves off from Him, He always listens, and gives us the respect we sometimes deny Him, by being ever ready to accept us back.
The Salvation of Souls being the Supreme law means that, if sometimes one cannot follow the law, and can obtain the salvation of a soul without doing something evil then one can presume the permission to save that soul.
Lets use the example of a priest in Mortal Sin offering a Mass. First since Jesus is the primary celebrant of every Mass, as both Priest and Vicitim, and the Mass is not simply an act of the individual priest, the Mass itself is an action of God, no simply a rite of Man.
A priest who commits a mortal sin must be sorry for his sin, confess and be absolved before he offers a Mass, or he commits another Mortal sin. Now let us consider that the priest committed a Mortal sin, there is no other priest to hear his confession, and it is a Sunday or Holy Day of obligation, and there are a group of people who have the obligation to hear Mass. The priest can make an act of perfect contrition, and offer Mass so they may fulfill their obligation to worship God. While the priest has not gone to confession, (and must as soon as he is able) he does not sin by offering the Mass, because he did so not to be disobedient but because there were sould that needed to fulfill their obligation to worship God.
Now lets consider something less grave. A priest who uses the 1962 Missal is required to use a chalice and paten that has been consecrated jn a special rite by a bishop. The rite requires holy water, and holy oil, and a special rite. Under a church law that says he sins if he knowingly uses a chalice and paten that are not consecrated. A priest has a chalice and paten that are not consecrated. Priests are allowed to consecrate the chalice and paten only with a special indult, or permission from the bishop. If the priest cannot contact the bishop prior to using the chalice, he can safely presume that if he was able to contact the bishop and explain why he needed the permission to consecrate them, he would be be granted the permission. So the priest consecrates them without obtaining the permission and offers the Mass. Strictly speaking he has broken Church law, but the circumstances are such that he did what had to be done without doing something evil to help the souls of his flock.
One last example. Only human beings can be baptized. Unless one has the intent to not baptize, (an example is seminarians practice the rites before they are ordained deacons using a doll, to learn how to preform the rite, and they don’t intend to baptize the doll, which has no soul. So there is no baptism.) In the Middle Ages, when people did not understand that a child who was born with gross deformities was a full human being, the popular belief was that some animals or other creatures would sneak into a woman’s bedroom at night and impregnate her. Since it was unclear to them at that time if the child was a human or not, the Church had a rite called the Baptism of Monsters. (Monster was used at that time to denote grave deformities, not the mytlical creatures we see in modern comics and sci-fi) The priest or person baptizing would say, “If you are human; I baptize you…” The possiblity that there was a human soul, was enough to allow for the person who they were not sure of to be baptized, on the chance that there was a soul that could be saved.