Matthew is one of the two gospels (along with Luke) to include an infancy narrative. Unlike Luke, though, Matthew gives a greater emphasis on Joseph than on Mary. Matthew tells the story of how Joseph discovered that Mary was pregnant and intended to divorce her quietly, until he received a visit from the angel of the Lord. Matthew is also the only Gospel to include the visit of the Magi, and to share the story of the Holy Family fleeing to Egypt to escape Herod’s murderous designs. Mary is obviously involved in these events, but Matthew’s narrative places a greater emphasis on Joseph’s role than on hers (for example, the angel of the Lord appears to Joseph in his dreams to warn him, not to Mary).
Mary does appear later in Matthew, when the adult Jesus is preaching and Mary and his brothers come looking for him. (Matthew 12:46-50). This story is also seen in Luke and in Mark. And the Gospel begins with a geneaology of Jesus, in which Mary is mentioned by name (Matthew 1:16). Overall, though, Mary does not play as active a role in the narrative of Matthew as she does in Luke and in John.