The following comments from The Bible Knowledge Commentary should answer your questions.
27:51-53 (Mark 15:38; Luke 23:44-45). At the time of Jesus’ death, three momentous events occurred. First, the curtain of the temple was torn in two from top to bottom. This curtain separated the holy place from the holy of holies in the temple (Heb. 9:2-3). The fact that this occurred from top to bottom signified that God is the One who ripped the thick curtain. It was not torn from the bottom by men ripping it. God was showing that the way of access into His presence was now available for everyone, not simply the Old Testament high priest (Heb. 4:14-16; 10:19-22).
Second, at Christ’s death a strong earthquake occurred, splitting rocks (Matt. 27:51). Truly the death of Christ was a powerful, earthshaking event with repercussions affecting even the creation. A third event mentioned was recorded only by Matthew. The tombs of many holy (righteous) people (v. 52) were opened, probably at a Jerusalem cemetery. The NIV suggests that these saints were resurrected when Jesus died and then went into Jerusalem after Jesus’ resurrection. A number of commentators agree with this view. Many others, however, say that since Christ is the firstfruits of the dead (1 Cor. 15:23), their resurrection did not occur till He was raised. In this view, the phrase “after Jesus’ resurrection” goes with the words were raised to life and came out of the tombs. This is possible in the Greek, and is suggested in the KJV and the NASB. The tombs, then, broke open at Christ’s death, probably by the earthquake, thus heralding Christ’s triumph in death over sin, but the bodies were not raised till Christ was raised.
These people returned to Jerusalem, (the Holy City) where they were recognized by friends and family. Like Lazarus (John 11:43-44), Jairus’ daughter (Luke 8:52-56), and the widow of Nain’s son (Luke 7:13-15), they too passed through physical death again. Or some say they may have been raised with glorified bodies like the Lord’s. Walvoord suggests this event was “a fulfillment of the Feast of the Firstfruits of harvest mentioned in Leviticus 23:10-14. On that occasion, as a token of the coming harvest, the people would bring a handful of grain to the priest. The resurrection of these saints, occurring after Jesus Himself was raised, is a token of the coming harvest when all the saints will be raised” (Walvoord, Matthew: Thy Kingdom Come, p. 236).