There are many professed Christians who do not believe baptism is necessary for salvation. Many commentators even say it is not a mandatory thing to do. The conversion of Cornelius needs to be considered in such a discussion. Cornelius was a centurion of the Roman army. He lived in Caesarea.
Cornelius believed in God and evidently did everything he could to obey God. Cornelius had been praying to God, begging God for instructions. In Acts 10:6, an angel from God told Cornelius to send for Peter, who would tell him “what you must do” (NKJV). That means there were some things Cornelius had to do. Acts 11:14 adds to what the angel said. There it is recorded that Cornelius would be told words by which he and his house “will be saved.” So whatever Cornelius had to do was what would save him.
When Peter met with Cornelius, he started preaching to him and his house. While Peter spoke, the Holy Spirit came on Cornelius and others present there. They started speaking in tongues just like the apostles did on the Day of Pentecost. Notice that this was not something Peter told them to do. Neither did God giving them this ability saved them.
The Jewish Christians were amazed when Cornelius was given that ability. Peter asked the Jewish Christians if they could deny baptism to Cornelius and the others since obviously God provided that as a sign. No one responded negatively. So, Peter “commanded” Cornelius and those with him to be baptized (Acts 10:48). Notice that this is something Peter told them to do. Notice that he “commanded” it. That means it is absolutely necessary.
Study your Bible. Learn what is commanded. Obey those commands. Don’t let anyone tell you it is not necessary to obey God’s commands. If any of this is hard to understand, ask an adult to help you.