Define Bessel's inequality $$ \sum_{n=1}^N|a_n|^2\leq \|x\|^2 $$ where $a_n=\langle x,e_n \rangle$.
Lemma
Let $\{e_n\}_{n\geq 0}\subset H$ be a complete orthonormal set. If $x\in H$ and $a_n=\langle x,e_n\rangle$ then
$$
x=\lim_{N\rightarrow\infty} \sum_{n=1}^Na_ne_n=\sum_{n=1}^\infty a_ne_n
$$
Begining of the proof
Let $w_N=\sum_{n=1}^Na_ne_n$, for $N\geq M$,
$$
\|w_N-w_M\|^2 = \left\|\sum_{n=M+1}^Na_ne_n\right\|^2 = \left\langle\sum_{n=M+1}^Na_ne_n, \sum_{n=M+1}^Na_ne_n\right\rangle =\sum_{n=M+1}^Na_n\overline{a}_n=\sum_{n=M+1}^N|a_n|^2.
$$
By Bessel's inequality, $\sum_{n=M+1}^N|a_n|^2\rightarrow 0$ as $N,M\rightarrow\infty$ and so $\{w_N\}$ is Cauchy and by completeness of $H$ it converges to some $w\in H$ as $N\rightarrow \infty$. In other words $w=\sum_{n=1}^\infty a_ne_n$.
I do not understand Bessel's inequality implies the convergence $\sum_{n=M+1}^N|a_n|^2\rightarrow 0$ (I know it is tremendously basic).
Indeed, this is basic, and is not something specific to Bessel's inequality. If a series $\sum b_n $ converges, where $b_n$ are real numbers (or elements of a normed vector space), that by definition means that partial sums $S_n$ have a limit $b$. That is, for every $\epsilon>0$ there is $N$ such that $|S_n-b|<\epsilon$ whenever. Hence, the sequence $S_n$ is Cauchy: for all $m,n>N$ we have $|S_n-S_m|<2\epsilon$. In terms of the series, the inequality $|S_n-S_m|<2\epsilon$ translates into $$\left|\sum_{k=m+1}^n b_k\right|<2\epsilon$$
In your situation $b_n=|a_n|^2$.