I don't mean to be snarky, but you could ask the same question
of how anybody recorded the dialog of George Washington. During
the Whiskey Rebellion, when he put on his spectacles, and simply
told his men that he had grown old in the service of his
country, people remembered it. Likewise, there are five versions
of the Gettysburg address, depending on which transcription of
Abraham Lincoln's own writing you use. Of those five versions,
there are a few prepositional phrases that are modified, but to
call them anything other than the same speech would be to
stretch the grounds of credulity. Still, the variation is
sufficiently minor to where you'd have to be really, really
picky to ask, "How can we be sure of what Lincoln really said.
Before modern recording devices, there was no expectation that
these direct quotations would have been the same as a court
reporter. People would simply do their best to record, as
closely as possible what they heard. To be honest to the text is
to say that people pretty well agre