I found some interesting resources by both Matt Perman and Sam Storms on this question; their thoughts were important and helpful to me in thinking through this question. So, I will draw from the verses they referenced and some of their thoughts in answering you.
The main tension seems to be that we are familiar with what the Bible teaches about sin and salvation. In particular, that we are all made in God’s image, yet have become sinful rebels, and can only be saved through a relationship with Christ.
What would it mean, then, for an infant or young child to have a relationship with Christ and experience salvation?
However, there is a persistent sense that children are a unique case. More importantly, the Scriptures give us some reason to understand why this is.
We might find ways to justify to ourselves what we want (this is a very common human tendency and it is no better when Christians do it than when others do it).
So I think it is important, on such a delicate and sensitive subject, to carefully look at what the Bible explains to us.
In the first place, we have evidence of infants who appear to be saved by God. We see that this is David’s testimony of his own life (Psalm 22:9-10). This was also the experience of John the Baptist (Luke 1:15). In addition, David expected to meet his first son, who died very early, in the next life (2 Samuel 12:23).
Secondly, Deuteronomy 1:39 speaks about children, “who today have no knowledge of good or evil.” These children were exempt from God’s judgment upon the Israelites. The adults were forbidden from going into Canaan because of their sin and rebellion against God. However, their innocent children were allowed to go into the land.
Third, this idea is reinforced by Jesus’ teaching in John 9:41. Jesus says to the Pharisees, “If you were blind, you would have no guilt.” However, they are able to see God’s truth (and God himself in the flesh!) and yet they reject it for their own ways. To the degree that a child is ‘blind’ to the things of God due to their age or undeveloped cognitive capacity, we may be encouraged that they will not be held accountable to God.
Finally, we can be assured of God’s goodness. In Psalm 119:68 we read, “You are good and do good.” What a poetic and beautiful way to declare the complete goodness of God!
On the basis of these verses, and what seems to me to be careful reflection on them, I think we should be assured of God’s salvation for the unborn and for young children.
At the same time, we should be eager to teach our children about God, that they might never know a time when they did not know him. We see in Matthew 19 that Jesus was glad to have the children brought to him - it is the delight of every Christian parent to pray with their children and introduce them to Jesus from their first breath.