the four gospels are not in chronological order, Luke and Matthew are the two books that tell about the birth of Jesus and His childhood. Here is a shortened version of the whole account, the whole account is longer, so I am just going to cover the highlights of the account in my opinion.
Joseph’s and Mary’s home was in Nazareth before Jesus was born.
Lk1:26 In the sixth month of Elizabeth’s pregnancy, God sent the angel Gabriel to Nazareth, a town in Galilee,
Lk1:27 To a virgin pledged to be married to a man named Joseph, a descendant of David. The virgin’s name was Mary.
Mt 1:18 This is how the birth of Jesus the Messiah came about: His mother Mary was pledged to be married to Joseph, but before they came together, she was found to be pregnant through the Holy Spirit.
Mt 1:19 Because Joseph her husband was faithful to the law, and yet did not want to expose her to public disgrace, he had in mind to divorce her quietly.
Mt 1:20 But after he had considered this, an angel of the Lord appeared to him in a dream and said, “Joseph son of David, do not be afraid to take Mary home as your wife, because what is conceived in her is from the Holy Spirit.
Shortly before Jesus was born Augustus issued a decree, a census. that is why Joseph went to Bethlehem, everyone had to go to the place they were from, Joseph was from Bethlehem the house and line of David, but lived in Nazareth.
Lk2:1 In those days Caesar Augustus issued a decree that a census should be taken of the entire Roman world.
Lk2:2 (This was the first census that took place while Quirinius was governor of Syria.)
Lk2:3 And everyone went to their own town to register.
So Joseph went from his home in Nazareth to Bethlehem for the census, but while Joseph and Mary was in Bethlehem Mary went into labor.
Lk2:4 So Joseph also went up from the town of Nazareth in Galilee to Judea, to Bethlehem the town of David, because he belonged to the house and line of David.
Lk2:5 He went there to register with Mary, who was pledged to be married to him and was expecting a child.
Lk2:6 While they were there, the time came for the baby to be born,
In the fields nearby, an angel appeared to the Shepherds.
Lk2:8 And there were shepherds living out in the fields nearby, keeping watch over their flocks at night.
Lk2:9 An angel of the Lord appeared to them, and the glory of the Lord shone around them, and they were terrified.
Lk2:10 But the angel said to them, “Do not be afraid. I bring you good news of great joy that will be for all the people.
Lk2:11 Today in the town of David a Savior has been born to you; he is the Messiah, the Lord.
then the shepherds went and seen Jesus in the (food trough in the barn) were Mary had made a bed for Jesus.
Lk2:15 When the angels had left them and gone into heaven, the shepherds said to one another, “Let’s go to Bethlehem and see this thing that has happened, which the Lord has told us about.”
Lk2:16 So they hurried off and found Mary and Joseph, and the baby, who was lying in the manger.
Joseph and Mary stayed in Bethlehem because the town is near Jerusalem and knowing they were required to do the purification rites as written. They stayed in Bethlehem for eight days.
Lk2:21 On the eighth day, when it was time to circumcise the child, he was named Jesus, the name the angel had given him before he was conceived.
Lk2:22 When the time came for the purification rites required by the Law of Moses, Joseph and Mary took him to Jerusalem to present him to the Lord.
Lk2:23 (as it is written in the Law of the Lord, “Every firstborn male is to be consecrated to the Lord”),
Lk2:24 And to offer a sacrifice in keeping with what is said in the Law of the Lord: “a pair of doves or two young pigeons.”
After Joseph and Mary had done everything required they went back home to their house in Nazareth.
Lk2:39 When Joseph and Mary had done everything required by the Law of the Lord, they returned to Galilee to their own town of Nazareth.
The Magi was in the east when they saw the star rise at the birth of Jesus, then they left the east and came to Jerusalem.
the magi were in another country east so that took time to travel and arrive in Jerusalem.
Mt 2:1 After Jesus was born in Bethlehem in Judea, during the time of King Herod, Magi from the east came to Jerusalem
Mt 2:2 and asked, “Where is the one who has been born king of the Jews? We saw his star when it rose and have come to worship him.”
Mt 2:3 When King Herod heard this he was disturbed, and all Jerusalem with him.
After Herod called the magi secretly and found out from them the exact time. when the star appeared to them in the east.
Mt2:7 Then Herod called the Magi secretly and found out from them the exact time the star had appeared.
Mt2:8 He sent them to Bethlehem and said, “Go and search carefully for the child. As soon as you find him, report to me, so that I too may go and worship him.”
Yes Herod sent them to Bethlehem but the star the Magi saw before while in the east appeared again and the Magi went on their way and followed the star until it stopped over the house in Nazareth. the star that led them did not stop over Bethlehem but stopped over the house in Nazareth, then they went back to their country by another route.
Mt2:9 After they had heard the king, they went on their way, and the star they had seen when it rose went ahead of them until it stopped over the place where the child was.
Mt2:10 When they saw the star, they were overjoyed.
Mt2:11 On coming to the house, they saw the child with his mother Mary, and they bowed down and worshiped him. Then they opened their treasures and presented him with gifts of gold, frankincense and myrrh.
Mt2:12 And having been warned in a dream not to go back to Herod, they returned to their country by another route.
After the Magi left, that is when the Angel appeared to Joseph in a dream and instructed Joseph to take the child to Egypt and they left for Egypt which is not right around the corner it was more than a week’s trip to Egypt.
Mt 2:13 When they had gone, an angel of the Lord appeared to Joseph in a dream. “Get up,” he said, “take the child and his mother and escape to Egypt. Stay there until I tell you, for Herod is going to search for the child to kill him.”
Mt 2:14 So he got up, took the child and his mother during the night and left for Egypt,
Herod had every new born child under two years old was killed. For Herod wanted to make sure there was no misunderstanding in the time frame of when Jesus was born.
Mt 2:16 When Herod realized that he had been outwitted by the Magi, he was furious, and he gave orders to kill all the boys in Bethlehem and its vicinity who were two years old and under, in accordance with the time he had learned from the Magi.
After the death of Herod, Joseph took Mary and the child back to the land of Israel.
Mt2:19 After Herod died, an angel of the Lord appeared in a dream to Joseph in Egypt
Mt2:15 where he stayed until the death of Herod. And so was fulfilled what the Lord had said through the prophet: “Out of Egypt I called my son.”
Mt2:20 and said, “Get up, take the child and his mother and go to the land of Israel, for those who were trying to take the child’s life are dead.”
Mt2:21 So he got up, took the child and his mother and went to the land of Israel.
Mt2:22 But when he heard that Archelaus was reigning in Judea in place of his father Herod, he was afraid to go there. Having been warned in a dream, he withdrew to the district of Galilee,
Matthew 2:23 is written in such away some people view that as for the first time in Nazareth but that is not the case. Reference Luke 1:26 and Luke 2:4
Indeed a period of time had went by and that is why it may appear as if Joseph was coming to Nazareth for the first time in the way it was written but scripture does not support that,, but scripture does support it was a return to Nazareth because as we know Joseph and Mary had already lived in Nazareth even before Jesus was born, reference Luke 1:26 and Luke 2:4
When Joseph came back to Judea he was going to live closer to Jerusalem, IMO but since Joseph was warned in a dream not to live near Jerusalem. Because of that Joseph and Mary with Jesus went back and lived in Nazareth again.
Sadly the account written in the OT of Jesus being called a Nazorean (Nazarene) has been lost to time.
I believe it was written in one of the nine or so books mentioned in the OT that has been lost.
Mt2:23 and he went and lived in a town called Nazareth. So was fulfilled what was said through the prophets, that he would be called a Nazarene.
Lk2:40 And the child grew and became strong; he was filled with wisdom, and the grace of God was on him.
Each year while they lived in Nazareth they went to the festival.
Lk2:41 Every year Jesus’ parents went to Jerusalem for the Festival of the Passover.
Lk2:42 When he was twelve years old, they went up to the Festival, according to the custom.
Lk2:51 Then he went down to Nazareth with them and was obedient to them. But his mother treasured all these things in her heart.
Lk2:52 And as Jesus grew up, he increased in wisdom and in favor with God and people.