Okay, so just to be clear I am going to consider processes in which a photon and an atom at some energy level go in, and the photon and atom exchange energy (and momentum) such that a photon with a shifted (either higher or lower) energy comes out, while the atom ends up in a different internal electronic state than it started in. A general diagram looks like:
where non-resonant light comes in, and causes a transition between states 1 and 2 with the outgoing photon's energy also shifted in the corresponding way. I have not showed the momentum change, but that will be determined by the energies and the geometry of the situation. I've drawn this where $E_2>E_1$, but the reverse process is also possible in which the photon gains energy.
First of all, you are certainly right to wonder why this process shouldn't be allowed. As I've mentioned in a different context, a useful way to think about many physical processes, attributed to Gell-Mann, is that "everything not forbidden is mandatory." So, when the internal atomic transition + photon shift can be accomplished in a way that conserves energy, and angular and linear momentum (and also obeys some other selection rules such as those involving parity), we should expect that it is possible. And it is!
As mentioned, these processes are normally called "Raman scattering," and are an important tool in materials science for the study of vibrational levels of materials. However, to directly address the question of charles boyant, the idea of a Raman transition is more general than this. For example, in atomic physics, Raman transitions (in a slightly different form known as stimulated Raman) are often used to go between two spin states of an atom. In this case, the polarization of the photon must change along with its energy so that all conservation laws are obeyed.
Okay, so if this can happen why did you learn that atoms can only absorb light at certain frequencies that correspond to atomic transitions? There were probably two motives behind this simplification:
Although Raman processes are allowed, they generally occur with very low probability compared to absorption near a resonance, and also compared to scattering of photons without a change in photon energy. So in many cases they only have a very small impact on the overall atom-light interaction.
Because the photon never fully disappears, Raman scattering (as the name suggests) is normally thought of as an inelastic scattering process, instead of as a "partial absorption."
This way of distinguishing between absorption and inelastic scattering is particularly useful when comparing Raman processes to processes where the light is on resonance with an atomic transition. This would be the case, for example, in which the light is resonant with the 1->E transition, and the atoms can then decay both to states 1 and 2. This has a similar result to the Raman process, in the sense that photons of one energy come in and photons with a shifted energy corresponding to the difference between atomic levels come out. However, since the absorption is a resonant process, the transition strength, wavelength dependence, and actual atomic state during the process is different in these two cases.
An atom is nothing but a bounded state of electrons and a positively charged core called nucleus. The electrons in the atom are in bound state and so their energy levels are quantized. Also, it is possible to have quantized rotational and vibrational energy levels of the molecules. The way in which they differ is in the difference in the energy characterizing the transition from one state to another.
Possible ways in which a photon is absorbed by an atom or a molecule
If the energy level of the incoming photon is such that the electrons can have a transition from a state to some higher permissible state, then the photon energy level will be in the visible or ultraviolet range and we make use of this principle in electronic spectroscopy.
Suppose, a particular electron is in the energy state with energy eigenvalue $E_i$. There exists a higher energy level $E_f$. If the energy levels of the electron bound states are such that it precisely matches with the energy of the photon: $h\nu=E_f-E_i$, then the electron will get excited to the energy state $E_f$.
Now, if the incident photon energy matches the difference in the vibrational energy levels of any pair of states of the molecule, then it can cause transition from that vibrational energy state to the higher energy state. This energy usually lies in the infrared region and the technique is used in infrared spectroscopy.
For example, in the case of diatomic molecules, the vibrational energy levels are quantized and in a good sense they can be approximated to that of a harmonic oscillator: $E_n=\left(n+\frac{1}{2}\right)\bar{h}\omega$. So, if the photon energy is such that $h\nu=E_f-E_i$, the electron transits from the state $E_i$ to $E_f$, where $E_i$ and $E_f$ are given by the above equation of the harmonic oscillator and the states are defined by the quantum number $n=i$ and $n=f$.
Now, if the absorption of a photon can only affect the rotational energy levels of the molecule, then the absorbed photon will be in the microwave region. The spectroscopic technique making use of this principle is the microwave spectroscopy.
For example, the rotational energy levels of a diatomic molecule are given by: $\displaystyle{E_j=\frac{j(j+1){\bar{h}}^2}{2I}}$, where $I$ is the moment of inertia and $j$ is the angular momentum quantum number. In such a case, we can write: $h\nu=E_f-E_i$ and the bound state absorbs the photon and will get excited to the state with energy $E_f$, with $E_f$ and $E_i$ determined by the quantum number $j=f$ and $j=i$.
Now, the energy can be absorbed by the nuclei also. It can be elastic nuclei scattering (analog to very low energy Compton scattering by an electron. In this process, a photon interacts with a nucleon in such a manner that a photon is re-emitted with the same energy), inelastic nuclei scattering (the nucleus is raised to an excited level by absorbing a photon. The excited nucleus subsequently de-excites by emitting a photon of equal or lower energy) and Delbruck scattering (the phenomenon of photon scattering by the Coulomb field of a nucleus, also called nuclear potential scattering, which can be thought of as virtual pair production in the field of the nucleus. i.e., pair production followed by annihilation of the created pair). However, these processes are negligible in photon interactions.
Conclusion:
Absorption of a photon will occur only when the quantum energy of the photon precisely matches the energy gap between the initial and final states of the system. (the atom or a molecule as a whole) i.e., by the absorption of a photon, the system could access to some higher permissible quantum mechanical energy state. If there is no pair of energy states such that the photon energy can elevate the system from the lower to the upper energy state, then the matter will be transparent to that radiation.
So, if any of the above types of energy transition take place, that will affect the quantum state of the system as a whole (transits the system from one state to another). So one could say, as @annav pointed out, it is the atom (or the molecule) that absorbs the radiation and changes the energy levels of its constituent particles, depending on the energy absorbed. Anyway, a change in energy level of the electron, or rotational or vibrational energy levels of the molecules can be seen as changing the quantum state of the molecule. So, it's better to stick with the concept of the molecule as a whole absorbs the energy and changes its state to some higher energy state by changing the quantum state of its constituent particles.
Best Answer
There is a basic misunderstanding in your question.
An electron is an elementary particle of fixed mass. It can scatter off a photon, (which is also an elementary particle); if accelerated it can emit a photon, but it does not absorb it, because the electron's mass is fixed, and if it were able to absorb a photon - at the electron's center of mass - the mass would have to change, which contradicts observations and special relativity for elementary particles.
The terms absorption and absorbs are not usable with free electrons. It is the bound electrons in an atomic system, which may change energy levels in the atom when the atom absorbs a photon. So it is not the electron that absorbs the photon, but the atom.
The atom has energy levels, and if the photon energy coincides (within a small $ΔE$, the width of the energy level) with the transition energy of kicking an electron to an empty energy level, then the atom can absorb the photon (not the electron). So the answer to "why", above, is "because the photon has the appropriate energy to transfer the electron to an empty energy level".
If the photon energy does not coincide with transition energy of the atom, the photon may scatter with the spillover electric fields of the atom or molecule either elastically, or transferring energy and a lower energy photon continues on its way.
The relevant thought to keep is that an elementary particle cannot absorb a photon. Composite ones as atoms, molecules and lattices, can.