The grace that the sacrament provides, the sacramental grace mentioned by mrsdizzyd, makes up for the imperfect contrition in confession. Jesus, who is the principle priest in confession, himself makes up for our imperfect contrition in confession and forgives us our sins. Jesus doesn’t demand that we have perfect love for him in order to forgive us our sins in confession or none of us would probably ever be forgiven. For a catholic, an act of perfect contrition which reinstates one to sanctifying grace before confession includes the intention that one will confess their sins in confession soon. Without this intention of confessing in confession, perfect contrition doesn’t happen for catholics at least.
The sacraments of the Church are actions of Christ and they cause the grace they signify instrumentally from Christ, the author of grace. By Jesus’ life, passion, and sacrifice on the cross, he superabundantly atoned for our sins and merited all the graces we need for our sanctification and to reach heaven. Jesus instituted the sacraments as the principle means of applying what he merited for us by his sacrifice on the cross, namely, his grace and eternal life as St John says “And the Word became flesh and dwelt among us, full of grace and truth…And from his fulness have we all received, grace upon grace” (John 1: 14,16). The sacraments are simply in themselves, ex opere operato, causes and sources of grace from the action of Christ. There effect in us depends in a certain sense on our dispositions and cooperation with the sacramental grace and according to the measure of the grace given by Jesus and the Holy Spirit.