The dough traps bubbles released by the yeast because of the gluten present in it. The gas is caught in the elastic bit of the bread called gluten. When the proteins inside the dough develop contact with water, gluten takes form by swelling and creating a fine matrix in the dough. The amount starts to increase once the two ingredients are kneaded together. The elastic molecule makes the air bubbles get trapped in the dough.
To make the dough rise better, most recipes ask to leave the bread to rise twice. Once after the yeast is mixed and kneaded with the dough. Then again after an hour, the dough is kneaded again and left to rise for another hour. This helps the yeast eat sugar and burp more carbon dioxide in the dough to make it airier. The yeast keeps doing their hard work even after the dough is placed in containers and placed in the oven. And after the baking is done, you have a delicious, fluffy loaf of bread that is based on science but for sure tastes like magic!