Let's go to the Bible to see if such teaching is true.
In Titus 3:5, we read this... "Not of works of righteousness that we have done but by His mercy He has saved us". "Works of righteousness" are things men do to appear holy or righteous in other people's eyes like praying, going to church, giving alms, joining ministries, etc. The verse above clearly tells us that this will not save us. Only because of God's mercy that we are saved and not because of anything that we have done that is pleasing in other people's sight. This is consistent with what Ephesians 2:8-9 declares that it is only by the grace of God that we are saved through faith and not of good works that we have done which we may boast of.
But the question is, "Is water baptism a 'work of righteousness'?"
In the Gospels, we read the account of Jesus' water baptism. John the Baptist at first, did not want to baptize Jesus because he felt that he was not worthy to do it for he knew well who Jesus is. But this was what Jesus told him..."Permit it to be so now, for thus it is fitting for us to fulfill all righteousness." (Matthew 3:15). Jesus was saying that in getting baptized by water, He will be able to fulfill one of the many righteous acts He must do. So, it is clear from this passage that water baptism is a "work of righteousness" which Titus 3:5 tells us will not save us. Water baptism is a public declaration of someone who is already a Christian that he/she has decided to follow Jesus in his\her life.
So the next question is, "What then is the baptism that Acts 2:38 was talking about that seems to be a requirement for salvation?"
In Mark 1:7-8, John the Baptist said this... "There comes One after me who is mightier than I... I indeed baptize with water, but He will baptize you with the Holy Spirit." From this text, we see that Jesus baptizes us with the Holy Spirit. When does this happen? At the moment of conversion, we are spiritually baptized to God's family with the indwelling of the Holy Spirit. If we are not spiritually baptized to the family of God, we cannot receive the gift of salvation. And so, it is clear that the baptism mentioned in Acts 2:38 is not water baptism but the spiritual baptism that happens upon conversion.
Eternal life is a free gift, and the Bible is consistent with that declaration. God knows that on our own, we cannot attain the required goodness to get to Heaven. He solved that by offering His own goodness to us and offering His own blood to pay for all of our offenses against His Laws when He died on a cross 2,000 years ago. We need not attempt to do the impossible anymore... to attain goodness as God defines being "good" (sinless perfection). All we need to do is acknowledge our own sinfulness, repent and trust Jesus as the only source of salvation, and as God has promised, we right away receive from Him the promised eternal life.