Atoms and molecules are pretty much everywhere. From the iron-heavy center of Earth to the hydrogen-rich envelope of distant stars, nuclei and their attendant electrons are ubiquitous. It makes sense, then, that astronomers would want to sort out what atoms and molecules make up which astronomical objects and swim in the space between them. But they cannot just reach out, grab a hunk of star, and bring it back to the lab. They must do the analysis remotely and, as always in astronomy, using only light that telescopes passively receive.
Luckily for astronomers, each element and molecule, when heated or excited or transitioning, emits specific, discrete wavelengths of light. This radiation is the atom’s or compound’s fingerprint, uniquely identifying it, whether it lives on Earth or in space.