Why is the infrared heat from the sun not prevented from entering the earth's atmosphere by $\rm CO_2$ to the same extent that it is prevented from leaving the Earth's atmosphere?
The radiation from sun is shorter wavelength than the radiation from earth. $\rm CO_2$ absorbs radiation mostly at wavelengths that the earth radiates. See this illustration of a publication.
Scattering is important here. Absorption does not mean that atoms or molecules absorb some specific wavelength and attenuate it. Any atom re-emits it. But while the re-emitting, emitting direction is random.
So atmosphere acts as a big scatterer and atoms and molecules that absorb infrared like $CO_2$ scatter more and infinite absorbing and re-emitting traps the energy