When an atom is struck by electricity (or heat), it gains some energy. This "excites" an electron and causes it to jump from its normal energy level to a higher level. The electron then falls back down to its original state and releases some energy in the form of light.
One example from science class is the flame test where atoms are heated in a bunsen burner flame and they release light. Each type of atom releases a different colour. Since scientists know the colours of light released by different atoms, they can figure out which atoms are present in the distant stars by analyzing the colours released.
Another example from science class (and the neon restaurant sign) is a discharge tube. When atoms of a gas such as neon are trapped in a glass tube and electricity is passed through it, the neon atoms emit an orange-red glow!