Light interacts with matter in different ways, always depending on the frequency. High freq. means high energy (x-ray and gamma), and low freq. means low energy (micro and radio wave). Depending on the frequency, the light (which is an EM wave) will cause changes within the atoms and beyond.
The question you asked, "How do molecules absorb heat?" refers to the Infrared frequencies which are responsible for the 'heating up' of things. In early level physics classes we are taught that particles vibrate as long as their temperature is greater than 0 degrees Kelvin (-273.15 degrees C). The hotter they get, the more they vibrate. When IR (infrared) light strikes a water molecule (for example), the water will absorb an amount of energy equivalent to its frequency multiplied by Planck's constant.
$$E=h\nu$$
Due to the specific frequency of the IR light, the particle will resonate with that energy and produce a specific reaction, vibration!
Each type of EM wave in the EM spectrum is responsible for a certain interaction with matter.
However, to answer your question, we need to apply all this to the CO2 molecule, the main culprit in the warming of the earth... other than humanity itself.
CO2 is exposed to IR light from either the Sun or the Earth's processes. The CO2 absorbs this energy and transfers it to vibrational energy. The CO2 in the atmosphere traps this energy and keeps it from radiating out into space. Obviously, the CO2 likes to stay at the lowest energy level possible (most stable) so it tries to pass some of that energy to nearby particles, making them vibrate. This also explains conduction and entropy in thermodynamics. That is also why the poles' ice caps are melting even though they host the harshest cold temperatures in the world.