Hello! To answer your question, specifically about carbon dioxide, it can absorb and radiate heat inside Earth's atmosphere and thereby contribute to the greenhouse gas effect because...
1.Sunlight radiation is absorbed on the Earth & warms it up
2. Due to the Earth warming, it emits infrared light back toward space, but carbon dioxide absorbs it and causes the atmosphere to heat up. Carbon dioxide acts like a blanket.
3. The Earth becomes hotter than before
I hoped that this has helped some way, if you have an further questions feel free to shoot me a question or message. Good luck :)