Interlude 2. You are considering the numbers of the form $qp^k$ that are between $1$ and $n$, because you are trying to figure out how many multiples of $p^k$ you have in $n!$. $m=qp^k$ does not follow from $1\leq m\leq n$; it is an extra condition. That is, "Let's now look at the numbers of the form $qp^k$ with $\gcd(p,q)=1$ that are between $1$ and $n$."
Interlude 3. In order to figure out the largest power of $p$ that divides $n!$, we need to count how many times $p$ occurs in the prime factorization of $n!$; this is equivalent to counting how many times it occurs in the prime factorizations of each number $m$, $1\leq m\leq n$, and then adding. It will appear once for every multiple of $p$ that is not a multipe of $p^2$; twice for every multiple of $p^2$ that is not a multiple of $p^3$; three times for each multiple of $p^3$ that is not a multiple of $p^4$; etc. But that is hard to count.
Alternatively: once for each multiple of $p$; then one more for each multiple of $p^2$; then one more for each multiple of $p^3$; then one more for each multiple of $p^4$; etc. That's easy to count, because we just figured out exactly how many multiples of $p$, how many multiples of $p^2$, etc. there are between $1$ and $n$.
There are $\lfloor\frac{n}{p}\rfloor$ multiiples of $p$; $\lfloor\frac{n}{p^2}\rfloor$ multiples of $p^2$; $\lfloor \frac{n}{p^3}\rfloor$ multiples of $p^3$; etc. Add them up, we get the number of times $p$ shows up in the factorization.
What they are saying is, instead: focus on a single $m = qp^k$, $\gcd(p,q)=1$. How many times do we count $m$? Once for $p$, once for $p^2$, once for $p^3$, etc. up until we get to $p^k$.
Note that for $a,b,c,d \in \mathbb{R}$ we have
\begin{align}
(a^2 + b^2)(c^2 + d^2) = (ac + bd)^2 + (ad - bc)^2
\end{align}
This means if two numbers can be written as the sum of squares, then their product can also be written as the sum of squares. Consider the $q_j$. Each $b_j$ is even so write $b_j = 2b'_j$. We then have $q_j^{b_j} = (q_j^{b'_j})^2 + 0^2$ so each of them can be written as the sum of sqaures. Thus $q_1^{b_1} \cdots q_l^{b_l}$ can be written as the sum of squares. Similarly be Fermat's theorem on the sum of squares each $p_i$ can be written as the sum of squares, and thus $p_i^{a_i}$ can be written as the sum of squares. Also $2 = 1^2 + 1^2$. Thus the product $m = 2p_1^{a_1} \cdots p_k^{a_k} q_1^{b_1} \cdots q_l^{b_l}$ can be written as the sum of squares.
Best Answer
Consider the binary representation of $\,n+1 = 2^{k+1}+\sum_{j=0}^k b_j 2^j \;\mid\; b_j \in \{0,1\}\,$, then:
$$n = 2^{k+1}-1+\sum_{j=0}^k b_j2^j = \sum_{j=0}^k 2^{j}+\sum_{j=0}^k b_j2^j = \sum_{j=0}^k (b_j+1)2^j \quad \style{font-family:inherit}{\text{where}}\;\; b_j+1 \in \{1,2\}$$