CO2 and other large atmospheric molecules have the uncanny ability made possible by quantum mechanics to interact with infrared radiation (heat). In doing so, the rate of radiant heat’s escape into space is slowed down. Thus, the level of radiative energy present in the lower atmosphere is higher to the degree that these molecules are present.
https://scied.ucar.edu/carbon-dioxide-absorbs-and-re-emits-infrared-radiation
Ways of Explaining the Greenhouse Effect:
https://samslair.blogspot.com/2019/08/ways-of-explaining-greenhouse-effect.html?m=1