The mass of a garden plant primarily comes from carbon dioxide, a gas in the air. During photosynthesis, plants absorb carbon dioxide from the atmosphere and, along with water taken up from the soil, convert it into glucose and oxygen. The glucose contributes to the growth of the plant, leading to an increase in mass.
While minerals from the soil are also essential for plant growth (providing nutrients), the bulk of the mass comes from the carbon dioxide absorbed during photosynthesis. Oxygen and nitrogen, while important for other processes, do not contribute significantly to the mass of the plant in the same way that carbon dioxide does.