What ARE energy states
First, think of an electron as a wave. We are at a scale where particle-wave-duality matters. The electron has a periodic wavelength.
Then think of the electron as a particle. It orbits the nucleus periodically.
These two periodic behaviours must match. Let's clear this out:
I personally like to think of an electron as both wave-and-particle by imagining that it "moves so fast" that it "smears out as a stretched probability cloud" all around the nucleus. As if it is a "cloud" that "reaches" all around the nucleus.
Now, if it "reaches all the way around" and "meets its own tail", then it must end exactly as it started. Its "position" in its wave behaviour must be the same to start with as it is after exactly one full round (and again as it is after two rounds, and three and...). In other words: The orbital period must be an integer-multiple of the wavelength.
If this is not the case, then you would see an unstable electron. It would wobble around turbulently, changing its orbit randomly, until it finds a stable orbit that matches by being an integer-multiple of its wavelength. Thus, all electrons will have found a stable orbit.
The "orbital speed" needed to match such integer-multiple orbit requires the electron to carry a certain amount of energy. It cannot be in-between two integer-multiples of an orbit, because that would mean an unstable orbit, so it will have to absorb (or release) exactly enough energy to "jump" the entire way to a new motion and thus a new type of orbit.
why do changes in them produce photons?
Such an absorbed/released energy "chunk" is called an energy quantum. We have now established (with abstract analogies) the core idea of quantum mechanics. An energy quantum that is released will be sent off and leave the atom. We call this a photon. A photon is thus just an energy "chunk" or energy "package" on its way to a new home.
The stable orbits that the electrons find are called energy states. There are a few different variations that influence energy states; one is the "jumping distance" between orbits that we have described, another is the electron spins, since electrons with different spins are said to be at different energy states. There are in total 4 different so-called quantum numbers that determine the energy state.
This was the essence.