What do you get when you add $O(n)$ to itself $n$ times?
The notation $O(n)$ stands for a function which is bounded by $Cn$ for some constant $C&gt;0$ and large enough $n$.
If you have a two functions $f_1,f_2$ which are both $O(n)$, then so is their sum $f_1+f_2$: indeed, suppose that $f_1(n) \leq C_1n$ and $f_2(n) \leq C_2n$ for large enough $n$. Then $f_1(n) + f_2(n) \leq (C_1 + C_2)(n)$ for large enough $n$.
Similarly, if you have a single function $f(n)$ which is $O(n)$ and you add it to itself $n$ times then you get a function $nf(n)$ which is $O(n^2)$.
However, this fails when you add $n$ different functions which are $O(n)$. For example, consider the functions $f_k(n) = kn$ and the function $g(n) = f_1(n) + \cdots + f_n(n)$. Then $f_k(n) = O(n)$ for all $k$, but it is not true that $g(n) = O(n^2)$; rather, $g(n) = \Theta(n^3)$. (This means that $cn^3 \leq g(n) \leq Cn^3$ for some $c,C&gt;0$ and large enough $n$.)
If we know that the functions $f_k$ are uniformly $O(n)$, that is, there is a single $C&gt;0$ and a single $N&gt;0$ such that $f_k(n) \leq Cn$ whenever $n&gt;N$, then it does hold that $f_k(1) + \cdots + f_k(n) = O(n^2)$.
(It doesn't suffice to require just $C$ to be uniform. For example, if $f_k(n) = n+k^2$ then $f_k(n) \leq 2n$ for large enough $n$, but $f_1(n) + \cdots + f_n(n) = \Theta(n^3)$.)