Studying a proof of Bessels' inequality. something confused me here is the proof:
Lemma 1: Let $H$ be an inner product space if $\{ e_{1}, e_{2} ... , e_{n} \}$ is an orthonormal set then for all $h \in H$
$\sum^{n}_{k = 1} \langle e_{k},h\rangle^2 \leq ||h||^{2}$
Proof let $g = \sum^{\infty}_{k = 1} \langle e_{k}, h\rangle e_{k}$ (first question, why do we let g equal this? is it just '' a good idea''?
Then
$||g||^{2} = \langle g,g\rangle\\ =\langle\sum^{\infty}_{k = 1} \langle e_{k}, h\rangle e_{k}, \sum^{\infty}_{k = 1} \langle e_{k}, h\rangle e_{k}\rangle\\ = \sum^{n}_{k = 1} \langle e_{k}, h\rangle ||e_{k}||^{2}\\ = \sum^{n}_{k = 1} \langle e_{k}, h\rangle$
Now the above calculation, why do we suddenly get that we sum over n instead of $\infty$
$\forall h \in H$ \begin{aligned} 0 &\leq||h - g||^{2} = ||h||^{2} - 2 \langle h,g\rangle + ||g||^{2}\\ &= ||h||^{2} - 2\langle h,\sum^{\infty}_{k = 1} \langle e_{k}, h\rangle e_{k}\rangle + ||g||^{2}\\ &= ||h||^{2} -2 \sum^{\infty}_{k = 1} \langle e_{k}, h\rangle^{2} + ||g||^{2}\\ &= ||h||^{2} - 2||g||^{2} + ||g||^{2}\\ &= ||h||^{2} - ||g||^{2}\\ &\implies ||g||^{2} \leq ||h||^{2}\\ &\implies \sum^{n}_{k=1} \langle e_{k}, h\rangle^{2} \leq ||h||^{2} \end{aligned}
Again why do we get sum from $\infty$ suddenly becomes $n$
and how can this proof the inequality I mean there's no absolute value around LHS

You should have defined $g$ in the first place as a finite sum: $$g = \sum_{k=1}^n \langle h,e_k \rangle e_k.$$ Note the order in the inner product. Next your calculation of $\|g\|^2$ is incorrect. It should be $$\|g\|^2 = \sum_{k=1}^n |\langle h,e_k \rangle|^2.$$ This follows easily from the properties of the inner product and the fact the $e_k$ are orthonormal.
You can evaluate the inner product of $h$ and $g$ by $$\langle h,g \rangle = \langle h,\sum_{k=1}^n \langle h,e_k \rangle e_k \rangle = \sum_{k=1}^n \overline{\langle h,e_k\rangle} \langle h,e_k \rangle = \sum_{k=1}^n |\langle h,e_k \rangle|^2 = \|g\|^2.$$
Instead of considering $\|h-g\|$ just apply Cauchy-Schwarz to find $$\|g\|^2 = \langle h,g \rangle \le \|h\| \|g\|$$ which yields the inequality you want.
p.s. use $\langle$ and $\rangle$ instead of $<$ and $>$ for the delimiters on an inner product.