In the Gospel of Matthew, there are four recorded instances where Jesus spoke about His resurrection after three days. The first, found in Matthew 12:40, took place publicly in the presence of the Pharisees and teachers of the law. The remaining three - Matthew 16:21, 17:23 and 20:19 - occurred privately during His conversations with the disciples.
Matthew 12:40 (NIV)
For as Jonah was three days and three nights in the belly of a huge fish, so the Son of Man will be three days and three nights in the heart of the earth.
Matthew 16:21, 17:23 and 20:19 (NIV)
From that time on Jesus began to explain to his disciples that he must go to Jerusalem and suffer many things at the hands of the elders, the chief priests and the teachers of the law, and that he must be killed and on the third day be raised to life.
22 When they came together in Galilee, he said to them, “The Son of Man is going to be delivered into the hands of men. 23 They will kill him, and on the third day he will be raised to life.” And the disciples were filled with grief.
17 Now Jesus was going up to Jerusalem. On the way, he took the Twelve aside and said to them, 18 “We are going up to Jerusalem, and the Son of Man will be delivered over to the chief priests and the teachers of the law. They will condemn him to death 19 and will hand him over to the Gentiles to be mocked and flogged and crucified. On the third day he will be raised to life!”
There is uncertainty as to whether the chief priests and Pharisees based their decision to guard Jesus' tomb on their recollection of His words in Matthew 12:40. At the time, the metaphor of Jonah may have been too ambiguous to draw a clear conclusion. It's possible that they received information from Judas Iscariot, the betrayer, which sparked a renewed concern that Jesus' body might be stolen.
As for the disciples, it's plausible that they struggled to remember Jesus' foretelling of His resurrection. Grief can cloud understanding, and denial is a common response to deep sorrow, just as Jesus had foretold them in John 16:20-22:
20 Very truly I tell you, you will weep and mourn while the world rejoices. You will grieve, but your grief will turn to joy. 21 A woman giving birth to a child has pain because her time has come; but when her baby is born she forgets the anguish because of her joy that a child is born into the world. 22 So with you: Now is your time of grief, but I will see you again and you will rejoice, and no one will take away your joy. (NIV)