It's a great question because it is a basic question.
If you have some hydrogen but no energy source behind it or within it, you will not detect the hydrogen.
If you have an energy source within the hydrogen or behind it, but you have too much hydrogen (what the astronomers call optically thick, which is both absorbing and emitting) you will not observe the hydrogen, but only a smooth continuum. The accretion disk of a dwarf nova in outburst is optically thick and produces a continuum. Layers of a star BELOW the photosphere produce a black-body like continuum.
If you have an energy source within the hydrogen and the hydrogen is not optically thick (clever astronomers call this optically thin) then you can observe emission of the hydrogen lines.
If you have an energy source behind the hydrogen and the hydrogen is optically thin then you can observe absorption of the hydrogen lines.
We can observe both emission and absorption of hydrogen lines (which may or may not cancel each other) because the geometrical arrangement of the above scenarios are all combined into one composite spectrum. For example, an inclined Be star could emit UV radiation (continuum) that could ionize hydrogen in an optically thin disk that would cause hydrogen emission, but to get to the observer, the light (both from the continuum and the emission region close to the star) has to travel through more optically thin hydrogen to get to the observer, this would result in hydrogen absorption. The resulting spectrum would have continuum, emission and absorption.
Because objects are so far away, just the proximity of unrelated absorption and emission could produce both in the spectrum.