The verses within each surah may not be arranged according to the sequence of their revelation. Sometimes, verses were revealed to be in specific places within a particular surah based on the guidance of the Prophet Muhammad (may Allah bless him and grant him peace), who was receiving guidance from Jibril, peace be upon him, about the location of each verse.
There are surahs that were revealed in their entirety at once, but this does not apply to all surahs. Some surahs consist of verses revealed at different times and situations, and they are collected into one surah.
The Prophet (may Allah bless him and grant him peace) received revelation from Allah s.w.t, and the Prophet taught the Companions the order of the verses and surahs as he was commanded. The current structure of the Qur’an, in terms of the arrangement of the surahs, was established during the reign of the Companions after the death of the Prophet (may Allah bless him and grant him peace), and is believed to reflect the order that was followed in the Prophet’s time.
After the death of the Prophet, the Companions took upon themselves the task of collecting the Qur’an into one Qur’an to ensure its preservation. Othman bin Affan (may Allah be pleased with him), played a prominent role in this process. The Qur’an was compiled based on the main outlines left by the Prophet (may Allah bless him and grant him peace), and each verse was verified with the complicity of the Companions who memorized and wrote it during the reign of the Prophet (may Allah bless him and grant him peace).