Why do atomic spectra appear as lines?
The light is passed through a narrow slit.
A set-up of a prism spectrometer is shown below.
You'd want the image to be long as it is easier to see. However, you would not want a broad image as the bands might overlap, or even if they do not, their distance of separation would not be well-defined.
Hence, the ideal shape for an aperture would be a long, narrow slit.
Because atoms have quantized energy levels.
Take Infrared Spectroscopy for instance. Its peaks arise from the vibrational modes of molecules, not atoms.
The stretches and bends of bonds alter the dipole moment of the molecule, which is directly proportional to the strength of the IR peak.
IR peaks have width to them because the dipole moment changes while the molecule stretches and bends, changing their electron distribution and altering their receptiveness to the incoming light source; the integral under their peaks is nonzero and not small.
Atomic emission spectra, on the other hand (at least the kind that you're referring to), receiving a coherent/focused light source to excite the atom, generally have little to no width to their lines.
Some of their highest-energy electrons can get excited by photons of specific energies to an excited state.
Since their energy levels are quantized (i.e. they correspond to the principal quantum number
These electrons, if they do not become freely-moving, do not generate a continuous spectrum.