At the end of the day, the goal is that by the time children become independent and go out on their own, they sincerely WANT to do what's right and good, of their own accord. As a parent, you can arrange external circuмstances that are most conducive toward this goal. You can command and force certain behavior. But the internal dispositions, those are a function of grace and free will. Prayers and the Sacraments bring grace. Sacraments offer grace ex opere operato, but the application to the soul depends on the subject's cooperation and disposition. Same with prayer. Sure, people can move their lips, while having their hearts far from God. It's important to try instilling a habit of MENTAL prayer in the children, not just vocal prayer. We can try to persuade them that keeping the faith is in their own best interests (even if they're not motivated for doing the right and good thing for its own sake).
But, despite all this, you can lead the horse to water but you can't make it drink. There's that little pesky thing called free will. Look at Judas. If anyone was ever exposed to better example, a better environment, and closer to the Source of Grace Himself, than Judas, then I'd love to know who that was. At the end of the day, he rejected all that and was lost. I've seen parents do everything "right", and have all their kids turn into delinquents. I've seen parents do everything "wrong," and have their kids end up being great Catholics. God foreknows which souls He gives to which parents. Sometimes the more difficult cases are given to the better parents, while the easier cases are assigned to the worse parents. Sometimes the suffering caused to the good parents is intended for their sanctification. God alone knows all the reasons for who, why, what, and where everything was arranged. We must do our best, and attempt to save our own souls, but ultimately the salvation of other souls is out of our direct control. There's a temptation to say, "look at how bad those kids are; they must have had bad parents" or, the opposite, "look at how good the kids are; they must have had great parents." There's a temptation for parents whose kids turn out well to take credit for it and be proud, and for parents whose kids don't turn out well, to become despondent and despair, perhaps even of their own salvation. But nothing is that simple. God alone knows the truth and reality of the situation.
And it's also critically important that parents do not despair when their kids take a detour on the path to salvation when they reach their college years and young adulthood. St. Monica prayed and wept for decades, and her delinquent son became one of the Church's greatest saints ... and so did she. Augustine's straying undoubtedly contributed to her sanctification. One might argue that, had her son turned out great from the beginning, she would not have attained to the degree of sanctification and perfection that God led her to. So here's an example where the straying of her son was part of God's will to sanctify her. St. Rita's sons were delinquents, to the point that she prayed that they would die rather than lose their souls (as seemed inevitable). And see the degree of sanctification to which she was led by God.
I can hardly recommend enough to parents to lead their children through making the First Saturdays and First Fridays as soon as they're old enough (have received Holy Communion). If you do that, it's guaranteed by Our Lady and by God that they will ultimately be saved. That can be a source of comfort for you as they stray, that eventually they will come back and save their souls. It's not uncommon that the seeds planted by parents eventually, often many many years later, bear fruit in their ultimate conversion back to the faith. Even if the child buries the seed, it stays there, waiting for an opportunity to sprout. Sometimes, God knows that the children must wallow in sin for a while before they realize that these things can never make them happy, and that the grass is not in fact greener on the other side. Sometimes God will allow them to hit rock bottom so that they can realize this. So the prodigal son was at the point of trying to get food left over by animals and sleeping in pig stalls ... before he realized how good he had it in his father's house.
Sometimes children stray in their young adulthood, but then mature when they have children of their own. Suddenly they start to realize that maybe their parents weren't all that bad and were tying to do what was good for their children. This happens even naturally. I've seen people who cared little for health and nutrition, for example, until they had children, and then suddenly they became very conscious of trying to have them eat right. Similarly, people who may resent the discipline imposed by their own parents suddenly find themselves wanting to do the same for their own children, realizing thereby that their parents were merely attempting to do the same.
We must do our best and then leave the rest to God.