We are not saved by baptism. We are also not saved by the keeping of the ten commandments. We are sinners and remain sinners throughout this earthly life. We will fail God over and over in our obedience to Him. We could never be saved by trying to keep even the smallest list of commandments.
Baptism is the public announcement and symbol of our personal salvation.
And obedience to all of God's commands is important as the outworking of our love for Christ and to find peace and happiness in this life. But to put baptism and the ten commandments as the means of earning salvation is to get the cart before the horse. We are saved by faith in Jesus.