Sunlight passes through the glass of the greenhouse, gets absorbed by the plants and the greenhouse floor and converts to heat.
The heat is unable to escape the glass, stays inside the greenhouse and keeps it warm.
In nature, there are certain gases in the atmosphere
like CO2, methane, which allows the sun's heat to enter the
atmosphere but after reflection, these radiations cannot escape out of
the atmosphere due to these gases.
They help in increasing the
temperature and hence called green house effect.