If we square an integral, we also change the integration variable in one of the integrals. But why is this actually correct?
For example, say I have the following:
Solve $\int_{-\infty}^\infty e^{-x^2} dx$. Let $I=\int_{-\infty}^\infty e^{-x^2} dx$, so
\begin{align}
I^2 &=\bigg(\int_{-\infty}^\infty e^{-x^2} dx\bigg)^2\\
&= \bigg(\int_{-\infty}^\infty e^{-x^2} dx\bigg) \times
\bigg(
\underbrace{
\int_{-\infty}^{\infty} e^{-y^2}dy
}_{\text{Why}?}
\bigg)
\\
&=\int_{-\infty}^\infty\bigg(\int_{-\infty}^\infty e^{-(x^2+y^2)} dx\bigg)dy
\end{align}
But why is the following wrong: \begin{align} I^2 &=\bigg(\int_{-\infty}^\infty e^{-x^2} dx\bigg)^2\\ &= \bigg(\int_{-\infty}^\infty e^{-x^2} dx\bigg) \times \bigg(\int_{-\infty}^{\infty} e^{-x^2}dx\bigg) \\ &=\int_{-\infty}^\infty\bigg(\int_{-\infty}^\infty e^{-x^2-x^2} dx\bigg)dx \\ &=\int_{-\infty}^\infty\bigg(\int_{-\infty}^\infty e^{-2x^2} dx\bigg)dx \qquad ? \end{align}
Because changing the integrand's variable doesn't change the value of the integral:$$\int_{a}^{b}f(x)dx=\int_{a}^{b}f(y)dy$$the same argument holds for summation as following$$\sum_{n=a}^{b}k_n=\sum_{m=a}^{b}k_m$$also we know that$$\left(\sum_{n=a}^{b}k_n\right)^2=\left(k_a+...+k_b\right)^2=k_a^2+...+k_b^2+2k_ak_{a+1}+...+2k_{b-1}k_b$$and$$\sum_{n=a}^{b}k_n\sum_{m=a}^{b}k_m=(k_a+...+k_b)(k_a+...+k_b)$$which by expanding the terms and rearranging them leads to$$\left(\sum_{n=a}^{b}k_n\right)^2=\sum_{n=a}^{b}k_n\sum_{m=a}^{b}k_m$$since integral is intrinsicly a summation, this can be generalized to integral operator either.