Both Matthew and Mark state very clearly that at the arrest of Jesus in the garden, all his disciples fled:
Matthew 26:56b “…Then all the disciples deserted him and fled.”
Mark 14:50 “ And they all deserted him and fled.”
Yet both Matthew and Mark mention that Peter made his way to the courtyard of the high priest. Clearly, that they have all fled does not mean some of them could not make their way back to see what happened to Jesus. At least we know for sure Peter fled and then went to see Jesus at the high priest’s courtyard.
John’s gospel is the only account that mentions John being at the house of Annas to see Jesus condemned by the sanhedrin, and later on stood by Mary at the foot of the Cross. Here is a theory that I heard somewhere before:
John, like all the rest of the apostles, did flee for his life after Jesus’ arrest. However, he was tasked with the duty of keeping Jesus’ mother Mary up to date. So before he went hiding, he went to inform Mary about Jesus’ arrest. Once Mary knew about it, however, she requested John to take her to Jesus. As a result, John could not run, since Mary refuse to be far from her son in his most crucial hours. Because of Mary, John became the only disciple who accompanied Jesus throughout His entire trial, passion, condemnation, crucifixion and death. John could represent the Church to stand near Jesus, all thanks to Mary, the most faithful disciple and the first companion of the Cross.
We too must stand by Jesus, and Mary too will be our best companion, for she knows best how to gather us all near Jesus and not run away. Amen!