The energy levels of electrons in atoms are quantized, meaning they can only occupy certain discrete energy states. When a photon interacts with an electron, it can only be absorbed or emitted if its energy matches the energy difference between the electron's initial and final states.
While the frequency of photons exists on a continuous spectrum, the energy levels available to electrons in an atom are discrete. However, due to the broad range of frequencies and energies encompassed by the electromagnetic spectrum, there is a high probability of finding photons with energies that match the energy differences between the electron energy levels.
The probability of a photon having the exact energy required to excite an electron depends on the specific energy level structure of the atom or molecule. In many cases, there are multiple energy transitions available, and photons with a range of energies (corresponding to different frequencies) can cause transitions between these levels.
Moreover, even if a photon's energy does not exactly match an energy level transition, there is still a possibility of interaction. This is because electrons can absorb or emit photons through processes such as stimulated emission, where the presence of nearby photons can assist in the excitation or de-excitation of an electron.
In summary, while the discrete nature of electron energy levels in atoms means that not all photons will have exactly the right energy to excite an electron, the broad range of energies and frequencies within the electromagnetic spectrum allows for a high probability of finding photons that can induce transitions between electron energy levels.