It all depends on the circumstances and understanding of the person at their previous baptism.
Before baptism there must be repentance and belief (Acts 2:38; Matthew 28:19-20; Mark 16:15-16), so any previous “baptism” is not really baptism if it was not accompanied by any sort of belief. Thus baptism of babies is not baptism at all in a biblical sense.
In Ephesians 1:4-6 we read
There is one body and one Spirit—just as you were called to the one hope that belongs to your call— 5 one Lord, one faith, one baptism, 6 one God and Father of all, who is over all and through all and in all.
So there is only one baptism and one faith, and the baptism must follow a belief in the one faith.
There is an interesting biblical precedent for rebaptizing someone:
And it happened that while Apollos was at Corinth, Paul passed through the inland country and came to Ephesus. There he found some disciples. 2 And he said to them, “Did you receive the Holy Spirit when you believed?” And they said, “No, we have not even heard that there is a Holy Spirit.” 3 And he said, “Into what then were you baptized?” They said, “Into John’s baptism.” 4 And Paul said, “John baptized with the baptism of repentance, telling the people to believe in the one who was to come after him, that is, Jesus.” 5 On hearing this, they were baptized in the name of the Lord Jesus.
This raises the question: were they rebaptized because John’s baptism was insufficient, or were they rebaptized because their understanding of the gospel was insufficient?
This is the only example of rebaptism in the Bible, so we are left to guess the precise reason. We do know that hundreds (possibly thousands) of Jewish people were baptised by John and later became followers of Jesus, including the apostles (see John 3:5-6,22-30). There is no record of any of them being rebaptised apart from these people in Ephesus. So I suggest that the people in Ephesus were rebaptised because of their poor understanding of the gospel, rather than because of John’s baptism being insufficient.
The nub of the question is what details of the “one faith” need to be part of the understanding of the person being baptised before it can be considered a true biblical baptism. It would seem that anyone baptised without understanding that there is a Holy Spirit would need to be rebaptised. But what if their understanding the gospel was more complete than this, but still missed out some important aspects? The Bible provides no explicit guidance on this question, and different people will come to different conclusions about what is required.