How was the preservation of Quran done?

All the previous scriptures (The Torah, The Injeel) that were revealed before The Qur’an were distorted and fabricated as time passed. As for The Quran Allah, The All-Mighty took it upon himself to preserve it till the end of time as He says in Surah al Hijr Chapter 15 Verse 9:

Indeed, it is We who sent down the message [i.e., the Qur'an], and indeed, We will be its guardian.

The Qur’an was revealed to the Prophet Muhammad (peace be upon Him) over 23 years, from the age of 40 to his death at the age of 63. Throughout those 23 years, the Prophet (peace be upon Him) endeavored to share the revelation with those around him as soon as it came. He did this verbally, as he couldn’t read or write, but he strongly encouraged others around him to write down the revelation, as well as memorize it. This was the basis of how Muslims believe the Qur’an became preserved, not purely through written or oral means, but with both strengthening the other. The companions around him constantly strove to memorize the verses, with many eventually memorizing the entire book, and simultaneously wrote these verses on parchment, bone, wood, stone, basically whatever they had around them. Over time at least 65 companions functioned as scribes for the Prophet (peace be upon Him), who eventually established a school in Madinah dedicated to teaching 900 of his companions to read and write.

With the death of the Prophet (peace be upon Him), the leadership of the Muslim community passed to his close friend Abu Bakr, who was quickly beset by conflict on the outskirts of the now considerably large Muslim state. This conflict led to the battle of Yamamah, which saw many of those who had memorized the Qur’an killed. Whilst many huffaz (memorizers of The Qur’an) remained, it highlighted the critical issue of preserving the entirety of the Qur’an, which was in danger if the memorizers were all killed. Abu Bakr decided to appoint Zaid ibn Thabit to compile all of the written verses of the Qur’an into one collection, using only those verses which had been written in the presence of the Prophet (peace be upon Him) himself. These manuscripts would then be verified by those who had memorized the entire Qur’an at the hands of the Prophet himself.

This was where the important concept of tawatur, or multiply attested sources, came into play. In order to be 100% sure that a verse of the Quran was in fact a verse of the Quran, it needed to have multiple independent chains of transmissions from different memorizers of the Quran. In this way, any verse that came to Zaid could be corroborated through both written and oral means, essentially guaranteeing that every single verse put in the final book was conveyed by the Prophet (peace be upon Him). Once this had been completed by Zaid, he penned the completed text which became known as the Suhuf, and gave it to Abu Bakr. This was now the official text of the Qur'an.