Even before the time of Jesus, many mystery religions of the ancient Mediterranean had some sort of ceremony that people had to do in order to join the cult. Some of these, like the Eleusinian mysteries, involved dipping yourself in water to wash away your past life, and to show that you were beginning a new life.
Christianity, from the very beginning, also had this idea of dipping yourself in water, which is called baptism. Before Jesus began preaching, he had himself dipped in water by his cousin, John, who is therefore called John the Baptist.
During the Roman Empire, Christians, like other people, were usually baptized as adults. That way they were old enough to understand what they were doing. In fact, people often waited to be baptized until they were dying. If being baptized washed away all your sins, so you could go to Heaven, people wanted to wait until the last minute so that they would be sure of going to Heaven. If you got baptized earlier, you might do something bad, and not go to Heaven after all. The emperor Constantine, for instance, was not baptized until he was dying, in 337 AD.
But later on, in the Middle Ages, people began to worry about dying by accident, quickly, without having time to get baptized. Then people started baptizing their babies, to be sure of getting it done in case the babies died.
Learn by doing: were you baptized? why or why not?
More about John the Baptist