Hadith are the Prophetic words and Sunnah are the Prophet's actions. Alongside memorizing and writing the Quran, many companions of Prophet Muhammad ﷺ memorized and copied his hadith and sunnah in to writing format, especially those that had very close interactions with him and spent more time with his blessed personality. The companions memorized and collected the Prophetic traditions when accompanying him, and after his passing away learned those that were missed from other more learned companions.
The collection of Abu Bakr (r.a)
According to Ayesha (r.a), Abu Bakr (r.a) had originally a collection of over five hundred traditions, and he deposited the compilation with her for custody. Ayesha (r.a) relates that one night she noticed that Abu Bakr (r.a) felt very restless. He tossed about in the bed, and could not sleep. Ayesha (r.a) got worried whether he was suffering or was worried. He made no reply, but remained restless throughout the night. The following morning he asked Ayesha (r.a) to bring him the collections that he had deposited with her. She brought the compilation and he set fire to it. On the inquiry of Ayesha (r.a), Abu Bakr (r.a) explained his conduct: "The collection contained many traditions that I had heard from other people. I thought that if I died and left behind traditions accepted by me as sahih (authentic), but really not so, then I would have to answer for that." Thus Abu Bakr (r.a) collected himself and in fact did not condemn in any way this act of collecting traditions but burned them only due to fear of personal accountability before Allah ﷻ, if even one of them resulted in being incorrect. Therefore its not the collection he disliked but his personal accountability due to deep consciousness of Allah ﷻ that he feared.
Hadith collection during Umar's rule
It was during his rule that Umar (r.a) laid the foundation for the practice of ilm al hadith (science of hadith), process used for the hadith preservation by subsequent generations of Islamic scholars. The practice with Umar (r.a) was that if any new problem cropped up, he announced the issue in the public assembly, and inquired if any of them remembered any tradition of the Holy Prophet ﷺ on the subject. Those who narrated any tradition were required to produce some witnesses in support of the tradition. If such statement was duly corroborated and was in accordance with the spirit of the Quran as well as common sense it was adopted and applied to the facts of the case in hand. In this way a rich corpus of Hadith was built up. To read more on the agreed principles for acceptance of a hadith in his era please read: What is Ilm Al Hadith (Science of Hadith).
Hadith collections by prominent sahabas (companions)
Its stated the Abu Ayyub Ansari (r.a), the famous Ansari companion, traveled for a month’s journey to Egypt listen to a hadith of the Prophet ﷺ directly from its narrator Uqba ibn Amir (r.a) who said that Prophet ﷺ said: “Whoever cover the faults of the believer Allah will cover his faults on Judgment day.” (Bukhari & Muslim). After hearing he did not even change his saddle of the horse and immediately left to come back. Jabir bin Abdullah (r.a) went a month’s journey from Madinah to Syria to secure authenticity of a tradition from Abdullah ibn Amr (r.a) as Abdullah used to himself write hadith. Abdullah (r.a) reports: "I used to write everything i heard from the Messenger (saw) as i wanted to Preserve it. The Quraish forbade me, saying "Do you write down everything that you hear (from him) and The Messenger ﷺ is a human being who sometimes speaks in anger and joy? (that is that he may say something emotionally that may not be worth writing)." So I stopped. Then i mentioned this to Allah's Messenger ﷺ. He pointed with his finger to his mouth and said "Write! By the One in Whose Hand is My Life! Nothing comes out of it (His Mouth) except the Truth!" 
Said ibn Al Musayyib (r.a) used to travel days and nights to listen to a single hadith from its original narrator. It is on record that companions like Ali ibn Abi Talib (r.a), Abu Huraria (r.a) and other companions collected their own sahifa (scripture) of Prophetic Hadith such as:
Sahifah (scripture) of Ali ibn Abu Talib (r.a)
Sahifah of Abdullah ibn Abi Auf (r.a)
Nuskah of Samurah Jundab (r.a)
Kitab of Abu Huraira (r.a)
Sahifah of Jabir Bin Abdullah (r.a) 
It was these books from which was derived most of the hadith literature later found in the authentic collections that we famously know today as Bukhari, Muslim, Abu Dawud, Ibn Majah, Tirmidhi etc.
 Masud-ul-Hasan, Professor. 1982. "Khalifa Abu Bakr - Mushaf, Hadith, Tasawwuf, Fiqh, and Poetry." Alim - The world's most useful Islamic software. Accessed 03 05, 2019. http://www.alim.org/library/biography/khalifa/content/KAB/16/2. (Masud-ul-Hasan 1982)
 Sunan Abu Daud of Imam Abu Daud, Hadith #3161
 Kazi, Mazhar. April 1, 2007. Guidance from Hadith & Sunnah. Al-Huda Publications - (Kazi April 1, 2007)
Define Ilm Al Hadith (Science of Hadith)
Ilm al hadith means Science of Hadith, which refers to the Knowledge of the scrutiny of hadith literature. Basically every hadith has a chain (isnad) of narrators that are going all the way back to the Prophet ﷺ. Studying biography of each narrator in a chain who transmits the hadith, in addition to comparing it with other chains of that same hadith, if any, including studying linguists of text as well as circumstances involved when particular hadith was narrated and others factors involved in recording are all included in the subject of ilm al hadith. There exists a few common misconceptions that the collection of hadith took place many years, in most cases 200 years, after the Prophet's death or that its initial collection was started by the students of the companions, and Prophet Muhammad ﷺ and his companions never supported or indulged in this activity. Such misconceptions are false because there is evidence that hadith were being collected during the Prophet's life (discussed in subsequent posts) and in fact the foundation and practice of Ilm Al hadith (Science of Hadith) was initiated by his companions, in a more organized manner especially during the rule of Umar ibn Khattab (r.a), the 2nd successor of Prophet Muhammad ﷺ.
Foundation of Ilm Al Hadith (Science of Hadith)
Umar (r.a) was the first to realize the necessity of the proper sifting of the hadith narrations. Those who narrated any hadith were required to produce some witnesses in support of the tradition. In this way a rich corpus of Hadith was built up. Umar (r.a) classified the traditions in two broad categories. One category of traditions pertained to religious, moral and social affairs pertaining to the community at large. The other traditions revolved round the person of the Holy Prophet ﷺ and pertained to his words and deeds as a human being i.e. the Prophet's Sunnah. Umar (r.a) distinguished between these two categories. All matters falling in the first category were binding and had the status of law. Umar (r.a) evolved the following principles on the basis of which the traditions were to be accepted:
(1) The report should be literally faithful;
(2) Every Hadith narrated should carry with it the name of the narrator and the chain of narrators;
(3) The narrators must be men of proven faith and integrity;
(4) In judging the veracity of a report the occasion and circumstances involved should be taken into consideration;
(5) The report should not be repugnant to the Holy Quran;
(6) The report should be rational.
Subsequent Developments in Ilm Al hadith (Science of Hadith)
By the end of 1st century Hijrah (100 AH - 720 CE) majority Companions passed away leaving their compilations behind including the framework and process for hadith evaluation taught to Tabi’een (their students). However this process needed to be a bit more supervised especially to avoid and separate the unauthentic traditions that began circulation in subsequent years. Therefore, during the rule of Umar bin Abdul Aziz (r.a) (717 - 720 CE), one of the Ummayad Caliphs (also known as 2nd Umar due to his piety), ordered the collection of ahadith on a large scale. He assigned learned scholars and hadith experts of Madinah such as Abu Bakr Ibn Hazam (Qadi of Madinah) and famous Ibn Shihab al-Zuhri, who were also students of Prophet's companions, Ayesha (r.a) and Anas bin Malik (r.a), expert hadith specialists and teachers. During the mid of 2nd century Hijrah (150 AH), hadith centers came to exist and scholars like Imam Malik (Died 179 AH) and Sufyan Thauri (Died - 168 AH) and several others opened their centers to teach hadith with rules as laid down by their predecessors.
In subsequent years rules of hadith collection were expanded and further conditions were added such as ilm al rijal (names of narrators and their biographies) and each hadith that included a chain (isnad) of narrators was classified based on the reliability of the narrators such as their piety, intelligence, if they were of forgetful nature, or if they were known to ever have lied. It was based on the strength of the narrators is how each hadith came to be classified with a status such as Dhaeef (weak), Sahih (authentic), Mutawattur (narrated through several chains), Hassan (good - lesser than Sahih), Ghareeb (strange due to some interruption in chain). Based on each status later compilations were made such as Sahih Bukhari and Sahih Muslim, with sahih meaning they are very authentic due to evaluation involved in their chains. One of the authors of Hadith book comments on this unique process: “Every Muhaddith (hadith expert) even today, when describes a hadith, he suffixes it with a specific name of a hadith denoting its level of authenticity (such as ‘Hassan’ or ‘Sahih’), then quotes the book of hadith where its documented (such as Musnad of Ahmad) and then prefixes it with an unbroken chain of narrators spreading over the last 1400 years through whom he received the hadith. No other religion, nation, party or even small group of people can show the parallel of what early Muslims did to ensure the authenticity of hadith and Sunnah.”
In subsequent centuries scholars studied these ahadith, added their comments to explanations given by their teachers and developed upon the wisdom and knowledge, resulting in science of Fiqh (practices/ruling) & Shariah (Islamic law). It is extremely sad to see that today many Muslims doubt the authenticity process of all hadith or some of it, without researching. And worst is that some even compare the uniquely systematic collection of this literature with collection of Christian Gospels that clearly lacked any consistent methodology and process in its compilation.
 Masud-ul-Hasan, Professor. 1982. "Khalifa bin al-Khattab - Hadith and Fiqh." Alim - The world's most useful Islamic software. Accessed 03 05, 2019. http://www.alim.org/library/biography/khalifa/content/KUM/16/1 . (Masud-ul-Hasan 1982)
 Kazi, Mazhar. April 1, 2007. Guidance from Hadith & Sunnah. Al-Huda Publications - (Kazi April 1, 2007)
Fiqh means the practices and rulings of Islam deducted by Islamic scholars from Quran and Hadith, the 2 primary sources of guidance. The need for systematization of Islamic knowledge such as Fiqh (practices and rulings) and other sciences such as ilm al hadith (sciences of hadith), Tasawwuf (science of spirituality) and all related subjects came to be developed later due the need of time.
During the Prophet's life, his example was right in front of the companions and whenever verses of Quran were revealed they were direct witnesses to it. Therefore the companions had direct access and first hand experience of the revelation process and its implementation unlike Muslims of the later centuries. They not only witnessed but also recorded them. Additionally they were a smaller community, concentrated in to one large group within the 2 major cities of Islam i.e. Makkah and Madinah. If any companion erred or forgot about a particular practice or ruling of the Prophet ﷺ, he was immediately corrected by the other who was living within the same community. After the passing away of the Prophet ﷺ, gradually Islam spread throughout the region and it accepted new people in to its fold. When new people entered Islam especially during the Rashidun period i.e. during rule of first 4 successors of Prophet Muhammad ﷺ (namely Abu Bakr (r.a), Umar (r.a), Uthman (r.a) and Ali (r.a)) the companions also spread to different regions. There they focused on the preservation of knowledge they had learned from the Prophet ﷺ and focused on teaching to the local people. This is how schools of thought came to be developed in early Islam that were named after each companions such as school of Abdullah ibn Masud (r.a) in Kufa and Abdullah ibn Umar (r.a) in Makkah, Abu Darda (r.a) in Damascus, Muadh bin Jabal (r.a) in Palestine and other companions went other places. Therefore, the people of each town had their own set of teachings they acquired from them and were satisfied.
Later on these cities were exposed to the hadith and sunnah information of the Prophet ﷺ which was taught in other cities by other companions which led towards the developing stage of various sciences such as ilm al hadith (sciences of hadith), fiqh (rulings and practices) and better understanding of Shariah (Islamic law). This also caused the need for pious among the knowledgeable to learn more by travelling to those cities which they did and compiled books and knowledge, and taught there, which then led towards development of major schools of thoughts such as 4 (Maliki, Sha'afi, Hanbali, Hanafi) and subsequent systematic compilations of hadith books. Many of these scholars that hailed from each major city of the Islamic world were all students of the teachers who themselves were students of either those learned from the Tabi'een (second generation or students of companions) or lived longer to have claimed learning directly from the companions. Therefore this is a process of traditional knowledge which has been handed down from the time of Prophet ﷺ to later generations through medium of pious and knowledgeable ones in a systematized manner.