Each year, pious Jews traveled to Jerusalem during Passover. Mary and Joseph again follow the laws of their religion but on the way back home, they discover that Jesus is missing.
This could easily happen because men and women often traveled apart from one another - the women in front, the men behind. It is easy to assume that Mary thought Jesus was with Joseph, and Joseph thought Jesus was with Mary. They eventually discovered that neither had Him.
They searched for Jesus and after three days found him in the Temple "talking" religion with the Temple priests. It was customary for religious leaders to set up a spot in the Temple to teach, with questions and answers to follow. Jesus was participating in this interchange when Mary and Joseph found Him in the Temple.