In Luke's Gospel, Nazareth was the home town of Mary and Joseph. They took Jesus back to Nazareth when he was just a few weeks old, after having presented him at the Temple in Jerusalem after Mary's ritual purification. Each year, the young family travelled briefly from Nazareth to Jerusalem for the Passover.
In Matthew's Gospel, Bethlehem was the home town of Mary and Joseph. When Joseph was warned in a dream that King Herod wanted to have Jesus killed, he fled with Mary and Jesus to Egypt until they received word that Herod was dead. This flight to Egypt must have occurred some years before the death of Herod, since he was afraid of a threat to his own reign, and was not overly concerned about his succession. So, some years after the birth of Jesus, the family began the return journey to Bethlehem but, Joseph being again warned in a dream, they turned aside and travelled to Galilee, where they settled in a city called Nazareth.
These are two very different stories that have Jesus going to Nazareth as a tiny baby or when he was a few years old, but neither is likely to be based on historical fact.
Chat with our AI personalities
Luke's Gospel says that after Jesus was born and it was time for Mary's ritual purification, Joseph and Mary took Jesus to Jerusalem and then to Nazareth.
Matthew's Gospel says that after Jesus was born, Joseph and Mary took Jesus to Egypt, where they stayed until King Herod died. They then returned to Judea but, following a warning from God, turned aside and travelled to Matthew 2:23 is not clear whether the family went immediately to Nazareth when they arrived in Galilee, or sometime later.