William I. answered  06/24/22
Experienced Physics and Math Skills Tutor...patient and expressive.
Elements have shapes in their electron clouds that are specific. 1s,1p,1d,1f (chemistry) or 2s,2p, 2d,2f.etc. Natural state of the atoms at "cool" temperatures is to have all the states in their lowest possible state so we usually don't see the emission spectra until additional energy is added. It can only be added by changing the shape of the electron cloud which is limited to Quantum steps. A step corresponds to a thin color corresponding to the energy of the photon as the atom loses energy. Different atoms starting in different states cause a series of quantum( stair step jumps in energy) . What you see is a conglomeration of atoms changing shape where the photon colors are specific to the change in shapes occuring in the sum of the atoms.