Allah the Exalted says; “Indeed, it is We who sent down the Qur’an and indeed, We will be its guardian.” (15:9)
When Prophet peace be upon him started reciting quickly with jibreel peace be upon him with fear of forgetting the revelation while Jibreel peace be upon him was conveying the Almighty’s message then Allah the Exalted revealed the verses;
“Move not your tongue with it, [O Muhammad], to hasten with recitation of the Qur’an. Indeed, upon Us is its collection [in your heart] and [to make possible] its recitation. So when We have recited it [through Gabriel], then follow its recitation. Then upon Us is its clarification [to you].” (75:16-19)
And so the revelation was then transferred from prophet peace be upon him to the companions. Some memorized them and some wrote them with the available materials with them. Specially the scribes who used to write for Prophet peace be upon him had the Qur’an in written form with them even during the life of the Holy prophet peace be upon him.