It does. However most thermal energy from the sun is at much shorter wavelengths and passes through the atmosphere unhindered. It warms the earth's surface (think of stone or sand on a sunny day, it can get too hot to touch). These warm surfaces radiate long wavelength infra-red and greenhouse gases trap those. That's the whole point. See
http://en.wikipedia.org/wiki/Greenhouse_effect for the details.