I'm trying to understand how to write the Killing form $B: \mathfrak{g} \times \mathfrak{g} \to \mathbb{R}$ defined by $$ B(X,Y) = \mathrm{Tr}(\mathrm{ad}_{X} \circ \mathrm{ad}_{Y}) $$
I'm trying to do this specifically for the Lie algebra $\mathfrak{g} = \mathfrak{so}(n)$, but I'm getting stuck right at the end. I know I $should$ be getting $B(X,Y) = (n-2)\mathrm{Tr}(XY)$ at the end of the day.
In my solution I try to keep things in terms of a general Lie algebra, and then specify to $\mathfrak{so}(n)$ at the end.
Assume $\mathfrak{g}$ is a matrix of size $n \times n$. Since $\mathrm{ad}_{X}(A) = [X,A]$, I'm thinking of the linear transformation $ad_{X}:\mathfrak{g} \to \mathfrak{g}$ as a matrix of size $n^{2} \times n^{2}$. Since $$ \left( \mathrm{ad}_{X} \circ \mathrm{ad}_{Y}\right)(A) = [X,[Y,A]] = XYA - YAX - XAY + AYX $$
If $M$ is my matrix (with components $M_{(j,k)(p,q)}$) corresponding to $\mathrm{ad}_{X} \circ \mathrm{ad}_{Y}$ in the sense that: $$ \left( \mathrm{ad}_{X} \circ \mathrm{ad}_{Y}\right)(A)_{jk} = \sum_{p,q=1}^{n} M_{(j,k)(p,q)} A_{pq} $$
I'm assuming then that $B(X,Y) = \mathrm{Tr}\left( \mathrm{ad}_{X} \circ \mathrm{ad}_{Y} \right) = \sum_{j,k=1}^{n} M_{(j,k),(j,k)}$. So after a little grinding, I find that: $$ \left( \mathrm{ad}_{X} \circ \mathrm{ad}_{Y}\right)(A)_{jk} = \sum_{p,q=1}^{n} \left[ X_{jp}Y_{pq}A_{qk} - Y_{jp}A_{pq}X_{qk} - X_{jp}A_{pq}Y_{qk} + A_{jp}Y_{pq}X_{qk} \right] \\ = \sum_{p,q=1}^{n} \left[ \sum_{\ell=1}^{n} \left( X_{j\ell}Y_{\ell p} \delta_{kq} + Y_{q\ell} X_{\ell k} \delta_{j p} \right) - X_{jp} Y_{qk} - Y_{jp} X_{qk} \right] A_{pq} \\ $$
Where $\delta$ is the kronecker delta. So my matrix components are: $$ M_{(j,k)(p,q)} = \sum_{\ell=1}^{n} \left( X_{j\ell}Y_{\ell p} \delta_{kq} + Y_{q\ell} X_{\ell k} \delta_{j p} \right) - X_{jp} Y_{qk} - Y_{jp} X_{qk} $$
Finally, this tells me that the Killing-form ends up looking like: $$ B(X,Y) = \sum_{j,k=1}^{n} M_{(j,k)(j,k)} \\ = \sum_{j,k=1}^{n} \left[ \sum_{\ell=1}^{n} \left( X_{j\ell}Y_{\ell j} \delta_{kk} + Y_{k\ell} X_{\ell k} \delta_{j j} \right) - X_{jj} Y_{kk} - Y_{jj} X_{kk} \right] \\ = 2n \mathrm{Tr}(XY) - 2 \mathrm{Tr}(X)\mathrm{Tr}(Y) $$
So $B(X,Y) = 2n \mathrm{Tr}(XY) - 2 \mathrm{Tr}(X)\mathrm{Tr}(Y)$, and so far I'm still working with a general Lie algebra $\mathfrak{g}$.
Looking at $\mathfrak{so}(n)$, I know this this is the set of skew-symmetric real matrices of size $n \times n$, which means they are all traceless. This simplifies my answer to $B(X,Y) = 2n \mathrm{Tr}(XY)$.
However, $2n \neq n-2$! Where am I going wrong in my proof? Am I taking too large of a leap in assuming that I can write the matrix M corresponding to $\mathrm{ad}_{X} \circ \mathrm{ad}_{Y}$ so easily?