Formulas for the number of spectral lines
To my understanding, it is simply single atom versus many number of atoms. For example, suppose one atom with an electron at energy level 7 ($n_2=7$). That electron can "de-excite" from $n_2=7$ to $n_1=6, 5, 4, 3, 2,$ or $1$. All those transitions give one spectral line for each. Thus, total of $1 \times 6 = n_1(n_2-n_1)$ (foot note 1) spectral lines would be present in the spectrum.

Similarly, when there were more than one atom in the sample, excited electrons ($n_2$) would be in different states $(n_2=2, 3, 4, 5, 6,....,\infty)$. For example, suppose we have aom population having electrons in all levels up to energy level 8 ($n_2=8, 7, 6,...$). Suppose those electrons "de-excite" to energy level 2 ($n_1=2$). Thus, electrons in $n_2=8$ can "de-excite" to energy levels $7, 6, 5, 4, 3,$ and $2$ meaning total of 6 spectral lines $(8-2=n_2-n_1)$. Some atoms with electrons in energy level $n_2-1=7$ can also "de-excite" to energy levels $6, 5, 4, 3,$ and $2$ meaning total of 5 spectral lines $(7-2=n_2-1-n_1)$, etc., etc. Thus, total numbers of spectral lines ($s$) in this case would be:
\begin{align}
s&amp;=6+5+4+3+2+1=21=\frac{42}{2}=\frac{7\times6}{2}\\
&amp;=\frac{(8-2+1)(8-2)}{2}\\
&amp;=\frac{(n_2+1-n_1)(n_2-n_1)}{2}
\end{align}

Foot note 1: Total number of spectral lines for single atom where $n_2=7$ should be: $1 \times 6 = (n_2-n_1)$ in the spectrum, not $n_1(n_2-n_1)$ as I originally suggested (Thanks @porphyrin for careful reading).