Baptism remits the temporal punishment due to sin that was committed until that point. As the Council of Trent put it,[INDENT]For, in those who are born again, there is nothing that God hates; because, There is no condemnation to those who are truly buried together with Christ by baptism into death; who walk not according to the flesh, but, putting off the old man, and putting on the new who is created according to God, are made innocent, immaculate, pure, harmless, and beloved of God, heirs indeed of God, but joint heirs with Christ; so that there is nothing whatever to retard their entrance into heaven.
(See also Catechism of the Catholic Church 1263).
[/INDENT]So if a man is baptized the moment he turns 40 years old, he won’t suffer from any temporal punishment due to the sins he committed in the previous 40 years.
It helps to consider the nature of “temporal punishment”: it’s not a penalty imposed from without, but it comes within the nature of sin itself. The ***Catechism ***describes this punishment as the “unhealthy attachment to creatures”.
Purgatory in this perspective is a transition in which we are healed of the attachments that we’ve inflicted on ourselves by choosing creatures — especially the #1 Creature: “Me” — over the Creator, without whom our hearts cannot rest.