Thousands of times a day, people quote Jesus. I have sat in church pews and heard quotes from Jesus.
There is no record of anyone who wrote the quotes being present when the words were spoken. We have no record of who was present.
Educated people back at the time when the Bible was written would not have believed these were the actual words of Jesus. Belief they are literal is a more modern concept.
The style of writing about events back at that time was to tell the story through the voice of someone supposedly involved. But, it was not actual speech. It was made up by the writer.
The writer may have been based it on something he had read or heard about. But, it was not the actual spoken word.
The source for this is the Greek historian, Thucydides (460-395 BC). He wrote histories of events of that time and included many “speeches”. But, he made it clear he had made up the speeches to conform to, “What is called for in each situation.”
Bart Ehrman points to this practice in the Book of Acts. There, Peter, an uneducated lower class fisherman who speaks Aramaic is “quoted”, as is Paul, an educated intellectual who speaks Greek.
Why would their speeches sound almost exactly alike, Ehrman asks? It’s because the unknown writer, called Luke, wrote them both.
It would be wise to take the “words of Jesus” with a grain of salt.