There are two explanations. The first is that the Holy Spirit inspired Mark and the other Gospel writers with the knowledge of what transpired in the Garden of Gethsemane, even though they were not present (or, in John’s case, were snoozing). This, of course, is exactly what the Lord promised would take place (Jn 14:26). The second explanation is that, after his Resurrection, during the 40 days he spent conversing with and teaching his apostles and other followers, Jesus recounted to them many of his otherwise unknowable conversations and actions, some of which were later recorded in the Bible, some of which weren’t. Remember, as John 20:30-31 and 21:25 point out, there were many things which Jesus said and did which are not recounted in the Bible.