We know that Jesus said and worked many more miracles than are simply mentioned in the Gospels.
St. John’s last words of his Gospel admits as much.
25 Now qthere are also many other things that Jesus did. Were every one of them to be written, I suppose that rthe world itself could not contain the books that would be written. - John 21:25
Just because the Gospels do not reveal everything or even how the Apostles became in possession of the events and conversations Our Lord had, when none of the Apostles where present is not hard to imagine.
There are basically just a few ways that the Apostles acquired this knowledge.
Either Our Lord revealed this to them himself and it is not mentioned in Scriptures as such. Or, the possibility that a third party revealed such information to the Apostles.
The Samaritan woman at the well was very talkative as the Gospels point out. She told everyone about Jesus. Perhaps she herself or one of the inhabitants from Sychar told the Apostles what happened. Again perhaps Our Lord told them after his resurrection! We may truly never know, while on earth, but then that is food for contemplation.
39 Many Samaritans from that town believed in him because of the woman's testimony, “He told me all that I ever did.” 40 So when the Samaritans came to him, they asked him to stay with them, and he stayed there two days. 41 And many more believed because of his word. 42 They said to the woman, “It is no longer because of what you said that we believe, for we have heard for ourselves, and we know that this is indeed the Savior of the world.” - John 4:38-42
As for Pilate’s conversation with Christ, it was not private. There were eyewitnesses! Did one of these tell the apostles what transpired between them or did Jesus mention it after his resurrection we may never know.
There is a tradition within some Christian denominations that Pilate’s wife became a believer and as such could have talked about it to Jesus’ Disciples!
Pontius Pilate's wife is the unnamed spouse of Pontius Pilate, who appears only once in the Gospel of Matthew, where she intercedes with Pilate on Jesus' behalf. It is uncertain whether Pilate was actually married, although it is likely. In later tradition, she becomes known as Procula (Latin: Procula) or Procla (Ancient Greek: Πρόκλα) and plays a role in various New Testament Apocrypha. At a later date, she acquires the name Claudia Procula in Western tradition, as well as other names and variants of these names. She is venerated as a saint by the Orthodox Church, the Coptic Church, and the Ethiopian Church. She has also frequently been featured in literature and film.
There are so many mysteries within the Scriptures and the Gospels in particular, that we have an endless source of contemplation and admiration as to try to even remotely understand how the Apostles know so much!
In the end, the Evangelists were convinced that this information would be useful for our edification and contemplation.
Ut in omnibus glorificetur Deus!