In Acts 22, the apostle Paul recounted the story of his Christian conversion. He told how the risen Christ sent a devout Jewish believer, Ananaias, who laid hands on him and said, "Brother Saul, Get up and be baptized, washing away your sins, calling on the name of the Lord" (v. 16).
What did Ananias mean?
Baptism symbolizes God in His mercy washing away our sins, based on Christ's redeeming death. The key to unlock Ananias' words is in the four word phrase, "Calling on His name." That phrase explains the preceding phrase, "washing away your sins."
According to Romans chapter 10, we call on Christ's name by putting our trust in Him. Romans 10:11-13 says, "Anyone who believes in him will never be put to shame.” For there is no difference between Jew and Gentile—the same Lord is Lord of all and richly blesses all who call on him, for, “Everyone who calls on the name of the Lord will be saved.”"
Paul says in this same paragraph that faith alone is sufficient for justification -- "For it is with your heart that you believe and are justified" (v.10). Justification is when God not only forgives us of our sins, but credits us with Christ's perfect righteousness in place of our sin-spotted, totally-inadequate righteousness.
Christ, in Matthew 10, said that any who confess Him before others, He will confess that person before the Father (Matthew 10:32). Paul in Romans 10 is repeating Christ's confession promise.
Confession of Christ with the mouth is the result of justifying faith in the heart, because "A good man brings good things out of the good stored up in his heart, and an evil man brings evil things out of the evil stored up in his heart. For the mouth speaks what the heart is full of." (Luke 6:44-45).
Justifying faith in the heart and saving confession of Christ with the mouth are two sides of one coin. The first (sincere heart-faith in Christ) always causes the second (verbal confession of Christ). Their relationship is that of cause and effect. We should be careful not to sever the connection between these two things. Also, confession is not the same thing as prayer.
Baptism is the Christian ceremony of verbal faith confession, and it was the ancient church's custom (unlike today) to baptize immediately, so that a person's baptism happened as near in time to their faith as possible. So, we can understand why the Bible associates baptism with salvation.
However, we must also take into account the total testimony of Scripture about salvation, to understand that baptism doesn't cause salvation, and is not its own separate condition of salvation.
The Bible gives testimony of thousands of years of sinners saved by grace, either without baptism or prior to it. People during the Old Testament times were saved the same way people today are -- as a free gift of God, received simply by trusting in the Lord's Gospel promise, apart from the sacraments. The standard of this was Abraham, in Genesis 15. Paul, in the first few verses of Romans 4, said that Abraham's salvation is our timeless example of how anyone is saved.
The thief on the cross, who confessed Christ to Christ, was saved without being baptized (Luke 23:42-43). God gave Cornelius the centurion the blessed Holy Spirit before Cornelius was baptized (Acts 10). Examples like these show God saving people without or before baptism.
The Bible closely links baptism with salvation, but not in a cause-and-effect sense. True faith comes out in the form of confession, and baptism is the ordained ordinance of confession. But verbal confessions can be false. We assume Judas Iscariot made a verbal confession of faith in Christ at some point in his life. But we know he was a child of the devil. A baptism can present a false picture. We know people who were baptized, sometimes when they were children, but then they truly came to Christ later in life.
Faith in Christ alone is sufficient to save. The Bible links baptism to salvation because baptism is the ceremony of confession. But baptism only saves, not from water coming on the body, but in the sense of it being a method of confession by which a believing person responds back to God, springing out of their grace-cleansed conscience, through Christ's resurrection (1 Peter 3:21).