Then when he says, reprove those who sin, he shows how they are to be punished, if proved guilty:
first, he shows that they must be punished publicly;
second, he adjures him to observe this, at I charge you, before God.
He says, therefore: reprove those who sin, whether they be priests or not, before all. Why? So that the rest also may have fear.
Yet the procedure in such cases is not the same as that in fraternal correction; because the judge is a public person. Consequently, he must aim at the common good, which is harmed by a public crime, because many are scandalized. Therefore, an ecc...lesiastical judge must inflict public punishments in such a way that others are edified: for because sentence is not speedily pronounced against the evil, the children of men commit evils without any fear (Eccl 8:11); the wicked man being scourged, the fool shall be wiser (Prov 19:25).
Note that he says, before all; which seems to be contrary to what is stated in Matthew: if your brother shall offend you, go, and rebuke him between you and him alone (Matt 18:15).
Augustine answers in a Gloss: distinguish the times and the sin, because the one is secret and the other public. The first needs a secret remedy, i.e., should be corrected in private; and this is the one the Lord has in mind; hence he says, offend you alone, as though in private. But the Apostle is speaking of a public sin, which calls for a public penalty. And this is signified by the dead whom the Lord revived. He revived the girl in her own home (Matt 9); and this signifies a secret sin. On that occasion he even cleared the room of people. But he revived the widow's son outside the gate in public (Luke 7); by which he showed that a public sin must be publicly punished.
Source: Commentary on 1 Timothy