Electromagnetic waves are produced by changes inside atoms and nuclei. The electrons in an atom can only have certain amounts of energy. When an electron drops from a higher energy level to a lower one, the atom gives out the extra energy as electromagnetic radiation. This is how atoms emit radiation.
The size of the energy change decides the frequency of the radiation. A small change gives a low frequency such as infrared. A larger change can give visible light or ultraviolet. Changes in atoms can therefore generate radiation over a wide range of frequencies, and the biggest changes in the inner electrons of heavy atoms can even give x-rays.
The process also works in reverse. When an atom absorbs electromagnetic radiation, an electron can take in the energy and move up to a higher energy level. If the radiation carries enough energy, the electron can be removed from the atom completely, and the atom becomes an ion. This is called ionisation.
Changes in the nucleus also involve radiation. An unstable nucleus can give out a gamma ray when it decays. Gamma rays have the highest frequencies in the electromagnetic spectrum. A nucleus can also absorb gamma radiation, and this can cause a change in the nucleus.