The subject we're looking at here is the quantization of energy absorbed and released by atoms, which is a fancy word describing the fact that atoms can only absorb or emit very specific amounts of energy (in the form of light) and nothing in between. This curious fact has everything to do with how electrons orbit the nucleus.
The electrons whirling around the nucleus do so only at specific distances and in specific patterns. Some orbit in spheres, others in dumbell-shapes, and still others in even odder patterns (a search for "orbital shapes" turns up a few relevant images). On top of that, smaller spheres (and other shapes) are nested within larger ones, in a manner Niels Bohr compared to the orbits of planets in the solar system (https://en.wikipedia.org/wiki/Bohr_model).
Now here's where the energy comes in. Electrons can "jump" between orbitals (unlike the planets, thank goodness!) when they absorb energy and move farther from the nucleus. When electrons jump orbitals, they gain potential energy, just like when we move farther from the Earth, we gain potential energy. The farther up we go, the more energy we have to expend on our way down: think jumping out of a 1st story window or a 2nd story window, or even a 3rd story window. Note that the electrons can only jump between the first, second, third, etc. "floors" (orbitals) of an atom. No mezzanines or mid-levels.
Obviously, the more electrons an atom has, the harder it is to map all of the specific energies it absorbs and emits. Hydrogen atoms are easy, however, as this equation depicts. Just plug in the starting shell #, the final shell #, and you've got your specific wavelength (energy) of light.
The logical question to ask now is "why do electrons orbit only in those specific levels?"
And that's a tough one, involving a crazy (interesting) amount of mathematics. Equations we've worked out from quantum mechanical theory describe "wavefunctions" for electrons that predict the probability of them being in a certain area (orbital) around the nucleus. They're convoluted, but brilliant. Take a gander here if you're curious: https://en.wikipedia.org/wiki/Wave_function.