This came to me when I saw the process of cheese making. And it's not really something I could think of people inventing.
The invention of cheese, bread, beer, and tofu started as part of the larger agricultural revolution of the neolithic age. Fermented grains, beer, and tofu likely was invented when oatmeal and gruel was left out and produce a rising product that was alcoholic when drunk as is and filling when baked( leaven bread feeds more people due to volume). Tofu is tied to chinese farmers curdling soy bean gruel using sea water by accident producing a multipurpose food stuff packed with protein.
Cheese and yoghurt on the other hand came from pastoralists who raised animals such as ( proto turkic peoples, proto indo european nomads of the pontic steppe) the is due to their diest being made up of mostly of animal products. Carrying milk in animal skin bags as a previous commenter mentioned lead to milk curdling in to cheese or yoghurt making it a convenient protein source.