Grace and validity are not interchangable in Catholic theology. In the case of baptism, sacramental grace is not conferred by mere validity. If a Catholic is baptized who does not have a full theological understanding of baptism (let's say he does not know that it is for the forgiveness of sins), the baptism is still a valid one. Even for those who obstinately reject what the Church teaches regarding the sacrament or for those who are attached to their sins and do not ask forgiveness for them before baptism, still have a valid baptism.
The reason this is so is found in a key point in Catholic doctrine, which is that Baptism impresses an ineffaceable and indelible mark of Character on the Soul which, once validly conferred, can never be repeated AND baptism also confers an infusion of Supernatural Grace, Gifts, and Virtues upon the person which renders men the adopted sons of God and confers the right to heavenly glory.
A valid baptism outside the Church (or in the above cases) indeed imprints the MARK of baptism upon the soul, but not the Grace. Thus, the one who is baptized is not sanctified. "Not unto salvation" as Aquinas says. To receive the sanctifying grace, the person who is baptized in such a state must go to confession with a priest in the apostolic successionthat is, ordained by bishops who are spiritual successors of Christ's first followers.