Carbon dioxide is called a greenhouse gas because it is one of the gases in the atmosphere that warms the Earth through a phenomenon called the greenhouse effect.
Image above: NASA
Carbon dioxide molecules in the atmosphere absorb long-wavelength infrared energy (heat) from the Earth and then re-radiate it, some of it back downward. This effectively traps heat around the Earth.
Carbon dioxide (CO₂) is one of several greenhouse gases in the atmosphere. They are referred to as greenhouse gases because, like the glass of a greenhouse, they let visible light from the Sun pass through the atmosphere but they absorb long-wavelength infrared energy from the Earth and keep the atmosphere warm. The idea of the warm interior of a greenhouse is just a useful metaphor for how gases in the atmosphere keep the surface of the Earth warm—there are no panes of glass in the atmosphere!