Here I refer to a particular book Molecular Quantum Mechanics by Peter W. Atkins and Ronald S. Friedman, but similar derivation could be found in many other texts.
So, when obtaining the explicit form of the Fock matrix elements for RHF formalism (p. 295 in 4th edition), authors go from
to
just by mentioning that $\psi_u$ is expanded as a linear combination of basis functions $\theta$.
The only way I could go from the first equation to the second one is by expanding the same spatial orbital $\psi_u$ on the left and on the right sides of integrand expression, i.e. before and after $1/r_{12}$, differently, $$ \psi_u = \sum_l c_{lu} \theta_{l} \quad \text{"on the left side"} \, , \\ \psi_u = \sum_m c_{mu} \theta_{m} \quad \text{"on the right side"} \, . $$
Is it true? And if yes, why on earth this should be done this way?