When atoms of elements are heated, they absorb energy. This moves the electrons in the atoms to different energy levels. When the electrons come back to their original energy state, the excess energy that had been absorbed is emitted in the form of photons of light. The atoms of each element absorb a level of energy that is unique. This results in the color of the light emitted also being different.
Compounds are made up of atoms of different elements. When they are heated, the atom of each constituent element emits light of a different frequency.
To determine the constituents of metal salts it is essential to heat them so that they can be identified by analyzing the color of light being emitted. This requires the compound to be dried and heated using a flame.