Greenhouse gases allow sunlight (shortwave radiation) to pass through the atmosphere freely, where it is then partially absorbed by the surface of the Earth.3 But some of this energy bounces back out towards space as heat. Of the heat emitted back to space, some is intercepted and absorbed by greenhouse gases in the atmosphere. This is because these compounds are made of three or more atoms. This molecular structure allows them to absorb some of the escaping heat and then re-emit it towards the Earth which increases global temperatures.
The ability of these gases to trap heat is what causes the greenhouse effect. So the more greenhouse gases you have in the atmosphere, the more heat stays on Earth. This process, which is very similar to the way a greenhouse works, is why the gases that can produce this effect are collectively known as greenhouse gases.