According to my chemistry teacher some years back, the bacteria eat the plants ad grow and multiply, Some types of bacteria also eat some of the nitrogen in the air. The nutrients in the plants become part of the bacteria, as does the nitrogen.
The rain then washes the bacteria into the soil, and when the bacteria eventually die they leave the nutrients in the soil where the bacteria were. The nutrients and the nitrogen are pretty much the same as the fertilizer that most of us add.
In a nutshell, the nutrients from the plants become part of the bacteria, the nutrients in the bacteria become part of the soil, and the nutrients in the soil become part of the next generation of plants, and then the plants die and are eaten by bacteria, and the cycle begins again. At least that was my understanding.