[guided]We now build an abstract Lie algebra from the common Cartan matrix alone. Let $\mathfrak{g}(A)$ denote the Lie algebra over $k$ generated by symbols
\begin{align*}
x_i,\ y_i,\ t_i \qquad 1 \leq i \leq \ell
\end{align*}
subject to the Chevalley-Serre relations
\begin{align*}
[t_i,t_j] &= 0,\\
[t_i,x_j] &= a_{ij}x_j,\\
[t_i,y_j] &= -a_{ij}y_j,\\
[x_i,y_j] &= \delta_{ij}t_i,\\
(\operatorname{ad} x_i)^{1-a_{ij}}(x_j) &= 0 \quad \text{for } i \neq j,\\
(\operatorname{ad} y_i)^{1-a_{ij}}(y_j) &= 0 \quad \text{for } i \neq j.
\end{align*}
Here $\operatorname{ad} x_i: \mathfrak{g}(A) \to \mathfrak{g}(A)$ is the adjoint map $z \mapsto [x_i,z]$, and $\operatorname{ad} y_i: \mathfrak{g}(A) \to \mathfrak{g}(A)$ is the adjoint map $z \mapsto [y_i,z]$.
The reason for introducing $\mathfrak{g}(A)$ is that every item in this presentation is determined by the entries $a_{ij}$ of the common Cartan matrix. No further structure from $L$ or $M$ appears in the definition. The Chevalley-Serre presentation theorem says that if a finite-dimensional semisimple Lie algebra over an algebraically closed field of characteristic $0$ is equipped with a Cartan subalgebra and an ordered basis of simple roots, then the corresponding simple positive root vectors, simple negative root vectors, and coroot elements generate the Lie algebra, and the defining relations are exactly the Chevalley-Serre relations determined by its Cartan matrix.
We verify the hypotheses for $L$. The theorem statement gives that $L$ is a finite-dimensional semisimple Lie algebra over the algebraically closed field $k$ of characteristic $0$, and the proof has chosen a Cartan subalgebra $H_L$ together with the ordered simple-root basis $(\alpha_1,\dots,\alpha_\ell)$. The generators $e_i,f_i,h_i$ were chosen from the simple root spaces and coroots, and the Cartan matrix is $A=(a_{ij})$. Therefore the Chevalley-Serre presentation theorem gives a Lie algebra isomorphism
\begin{align*}
\Phi_L: \mathfrak{g}(A) \to L
\end{align*}
determined on generators by
\begin{align*}
\Phi_L(x_i)&=e_i,\\
\Phi_L(y_i)&=f_i,\\
\Phi_L(t_i)&=h_i.
\end{align*}
We verify the same hypotheses for $M$. The algebra $M$ is also finite-dimensional and semisimple over the same algebraically closed field $k$ of characteristic $0$, and after the reindexing step its ordered simple-root basis $(\beta_1,\dots,\beta_\ell)$ has the same Cartan matrix $A=(a_{ij})$. The generators $E_i,F_i,H_i$ are the corresponding simple positive root vectors, simple negative root vectors, and coroot elements. Hence the same Chevalley-Serre presentation theorem gives a Lie algebra isomorphism
\begin{align*}
\Phi_M: \mathfrak{g}(A) \to M
\end{align*}
determined on generators by
\begin{align*}
\Phi_M(x_i)&=E_i,\\
\Phi_M(y_i)&=F_i,\\
\Phi_M(t_i)&=H_i.
\end{align*}
Thus both $L$ and $M$ are identified with the same presented Lie algebra $\mathfrak{g}(A)$, and the dependence on the common Cartan matrix is the whole content of this step.[/guided]