If $\mathfrak{g}=\bigoplus\mathfrak{g}_i$ is a semisimple Lie algebra, why does $\mathfrak{h}=\bigoplus\left(\mathfrak{h}\cap\mathfrak{g}_i\right)$?

Suppose that $K$ is the base field. Fix $h\in\mathfrak{h}$. Let $h_i\in\mathfrak{g}_i$ be such that $h=\sum\limits_i\,h_i$ (the $h_i$'s are unique). We claim that $h_i\in\mathfrak{h}$ for all $i$. Let $t\in\mathfrak{h}$. Write $t=\sum\limits_{i}\,t_i$ with $t_i\in\mathfrak{g}_i$. For $i\neq j$, $$\left[t_i,h_j\right]\in\mathfrak{g}_i\cap\mathfrak{g}_j=\{0\}\,,$$ so $\left[t_i,h_j\right]=0$. Ergo, $$\sum\limits_{i}\,\left[t_i,h_i\right]=[t,h]=0\,.$$ Since $\left[t_i,h_i\right]\in\mathfrak{g}_i$, we conclude that $\left[t_i,h_i\right]=0$ for every $i$. Thus, $\left[h_i,t\right]=\left[h_i,t_i\right]=0$ for every $t\in\mathfrak{h}$.

Because $h$ is a semisimple element of $\mathfrak{g}$, $h_i$ is also a semisimple element of $\mathfrak{g}$ (to be proven below). If $h_i\notin\mathfrak{h}$, then $\mathfrak{h}\oplus K\mathfrak{h}_i$ is a strictly larger toral subalgebra containing $h$, which is a contradiction. Thus, $h_i\in \mathfrak{h}$ for all $i$, so $h_i\in\mathfrak{h}\cap\mathfrak{g}_i$. Therefore, $$h=\sum\limits_i\,h_i\in\bigoplus\limits_i\,\left(\mathfrak{h}\cap\mathfrak{g}_i\right)\,,$$ whence $\mathfrak{h}\subseteq \bigoplus\limits_i\,\left(\mathfrak{h}\cap\mathfrak{g}_i\right)$. Since it is trivial that $\mathfrak{h}\supseteq \bigoplus\limits_i\,\left(\mathfrak{h}\cap\mathfrak{g}_i\right)$, $\mathfrak{h}= \bigoplus\limits_i\,\left(\mathfrak{h}\cap\mathfrak{g}_i\right)$, as required.

To show that $h_i$ is a semisimple element of $\mathfrak{g}$, we let $V^\lambda$ be the eigenspace of $\text{ad}_\mathfrak{g}(h)$ with the eigenvalue $\lambda\in K$. For each $i$, take $V_i^\lambda$ to be the intersection $V^\lambda\cap\mathfrak{g}_i$. Trivially, $\bigoplus\limits_{\lambda\in K}\,V^\lambda_i=\mathfrak{g}_i$. However, as $V^\lambda_i$ is the eigenspace with eigenvalue $\lambda$ of $\text{ad}_{\mathfrak{g}_i}\left(h_i\right)$, we see that $h_i$ is a semisimple element of $\mathfrak{g}_i$. Now, define $\tilde{V}^\lambda_i:=V^\lambda_i$ if $\lambda\neq 0$, and $\tilde{V}^0_i:=V^0_i\oplus\left(\bigoplus\limits_{j\neq i}\,\mathfrak{g}_j\right)$. Then, $\tilde{V}^\lambda_i$ is the eigenspace of $\text{ad}_\mathfrak{g}\left(h_i\right)$ with eigenvalue $\lambda$. Since $\bigoplus\limits_{\lambda \in K}\,\tilde{V}^\lambda_i=\mathfrak{g}$, we conclude that $h_i$ is a semisimple element of $\mathfrak{g}$.