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)