Oral traditions of scholars from the taabi'een and the Sahaba (RA) have closely preserved it. You don't know that because you're not educated about this matter. Do you know how long some Sahaba such as Anas ibn Malik (RA) lived for? Sxb come on mate... It was preserved similar to the way the Qur'an was preserved.
There's cities and villages in Mauritania and other parts of North Africa that never had a mushaf(quran) or kutub of hadith and have learned orally from teachers who learned from their teachers going all the way back to the prophet (saw)