It's where the energy comes from that determines the spectoral chsracteristicsspectral characteristics. For black body-body radiation it is the random collective motion of bulk material constituents. This motion is responsible for an object's temperature which is a statistical measure.
Molecular spectra as well as atomic spectra come from the motions of isolated atoms or molecules that are excited beyond their ground states, but still discrete quantum states. ForFor molecules, it is mostly vibrational or rotational motions of atoms that make up the molecules. For atoms, it is the electrons jumping from one orbital to another.