During those billions of years, the matter on our planet keeps changing its form. Water evaporates from the ocean, goes into the clouds and falls as snow and rain. Rocks get broken down into dirt that is washed as sediment into rivers. Plants take carbon dioxide gas from the atmosphere and convert it into solid sugars and starches. Earth still has oceans, mountains and atmospheric carbon dioxide because they are part of cycles - the water cycle, the rock cycle and the carbon cycle.
Earth is a recycling planet.
Essentially all the matter on Earth has been here since the planet was formed. The same matter keeps getting used over and over again. From a systems point of view, we say that Earth is essentially a closed system with respect to matter. Of course, Earth is not a totally closed system with respect to matter. For example, we are constantly bombarded by meteorites.