Did the killing of the Holy Innocents do something for their justification? Bellarmine thinks so. Others disagree. Bellarmine has to posit an ex opere operato action of martyrdom. But that's a real problem. So you have an adult who's a formal heretic and explicitly rejects the Catholic Church, but then is martyred for being a Christian. with the ex opere operato theory of Bellarmine, and the quasi-ex-opere-operato expression of St. Alphonsus, that heretic would be justified and saved. But the Church has taught otherwise dogmatically, that BoD does not apply to those who lack the Catholic faith. And infants lack the Catholic faith, since it has not been infused by the Sacrament of Baptism.
Nevertheless, here's the key. In no way could this action have constituted a substitute for Baptism for the Holy Innocents, since Baptism as a sacrament did not yet exist. It's the dogmatic teaching of Trent that there can be NO justification since the promulgation of the Gospel WITHOUT the Sacrament of Baptism. Even if one posits the existence of BoD and BoB, even in those cases the Sacrament of Baptism remains the instrumental cause of justification. Otherwise, you commit the heresy of claiming that people can be justified without Baptism. But in the case of the Holy Innocents, the Sacrament could not have been the instrumental cause of justification, since it did not exist.