As I understand it, greenhouse gases absorb infrared radiation from the sun.
That's not correct. The atmosphere is more or less transparent to the incoming solar radiation. About 29% of the incoming solar radiation is reflected back into space (that's the Earth's albedo). The remaining 71% is absorbed. Clouds and the atmosphere are responsible for a bit less than a third of that absorption. The other two thirds is absorbed by the Earth's surface.
This absorption is not where the greenhouse gases come into play.
The greenhouse gases instead come into play as a multi-layered blanket that keeps the surface of the Earth from cooling off. By way of analogy, suppose you went camping in the desert. While deserts can get quite hot during the day, they get surprisingly cool at night. A blanket protects you against those cool desert nights. While the blanket doesn't generate heat, it very much does slow down the heat transfer. It does this by emitting half of its thermal energy upward, half downward. This back-radiation makes your body remain warm. Add more blankets and you get even more protection.
While our atmosphere is more or less transparent in the visible range, the greenhouse gases make it opaque in thermal infrared. It is so opaque in the thermal infrared that our atmosphere acts as the equivalent of a multi-layer blanket. The solar radiation absorbed by Earth's surface is a bit less than 1/3 of the total energy received by the surface. The other two thirds is back-radiation from the Earth's atmosphere.
This topic is the subject of the Earth's radiation budget. Thanks to satellites, atmospheric scientists have been investigating the radiation budget for about half a century.
