[proofplan]
We describe explicit bases for each of the three matrix subspaces using the standard basis of the ambient [matrix space](/page/Matrix%20Space). Diagonal matrices are spanned by the basis matrices supported on a single diagonal entry. Symmetric matrices are parametrized by the diagonal entries and the entries strictly above the diagonal, while skew-symmetric matrices in characteristic not equal to two are parametrized by the entries strictly above the diagonal after the diagonal entries are forced to vanish.
[/proofplan]
[step:Fix the matrix-unit notation and define the three subspaces]
For $1\le i,j\le n$, let $E_{ij}\in M_n(k)$ denote the standard matrix unit whose $(i,j)$-entry is $1$ and whose other entries are $0$. For $A\in M_n(k)$, write $A^\top\in M_n(k)$ for the transpose matrix, defined by $(A^\top)_{ij}=A_{ji}$ for all $1\le i,j\le n$. By [citetheorem:8369], the family $\{E_{ij}:1\le i,j\le n\}$ is a basis of $M_n(k)$ over $k$.
Define
\begin{align*}
D:=\{A\in M_n(k): A_{ij}=0 \text{ whenever } i\ne j\}.
\end{align*}
Define
\begin{align*}
S:=\{A\in M_n(k): A^\top=A\}.
\end{align*}
Define
\begin{align*}
K:=\{A\in M_n(k): A^\top=-A\}.
\end{align*}
The sets $D$, $S$, and $K$ are $k$-linear subspaces of $M_n(k)$: the defining entrywise conditions are preserved under matrix addition and scalar multiplication. For $S$, this follows from $(A+B)^\top=A^\top+B^\top$ and $(\lambda A)^\top=\lambda A^\top$. The same identities give the corresponding verification for $K$.
[/step]
[step:Use the diagonal matrix units as a basis for the diagonal subspace]
We claim that
\begin{align*}
\mathcal{D}:=\{E_{ii}:1\le i\le n\}
\end{align*}
is a basis of $D$.
Let $A\in D$. Since $A$ is diagonal, its only possibly nonzero entries are $A_{11},\dots,A_{nn}$, and therefore
\begin{align*}
A=\sum_{i=1}^{n} A_{ii}E_{ii}.
\end{align*}
Thus $\mathcal{D}$ spans $D$.
If
\begin{align*}
\sum_{i=1}^{n}\lambda_i E_{ii}=0
\end{align*}
with $\lambda_i\in k$, then looking at the $(i,i)$-entry gives $\lambda_i=0$ for every $1\le i\le n$. Hence $\mathcal{D}$ is linearly independent. Therefore $\mathcal{D}$ is a basis of $D$, so
\begin{align*}
\dim_k D=n.
\end{align*}
[/step]
[step:Parametrize symmetric matrices by entries on and above the diagonal]
We claim that
\begin{align*}
\mathcal{S}:=\{E_{ii}:1\le i\le n\}\cup\{E_{ij}+E_{ji}:1\le i<j\le n\}
\end{align*}
is a basis of $S$.
Let $A\in S$. Since $A^\top=A$, we have $A_{ji}=A_{ij}$ for all $1\le i,j\le n$. Hence
\begin{align*}
A=\sum_{i=1}^{n}A_{ii}E_{ii}+\sum_{1\le i<j\le n}A_{ij}(E_{ij}+E_{ji}).
\end{align*}
This proves that $\mathcal{S}$ spans $S$.
Suppose
\begin{align*}
\sum_{i=1}^{n}\lambda_iE_{ii}+\sum_{1\le i<j\le n}\mu_{ij}(E_{ij}+E_{ji})=0
\end{align*}
with $\lambda_i,\mu_{ij}\in k$. Looking at the $(i,i)$-entry gives $\lambda_i=0$ for each $i$. Looking at the $(i,j)$-entry with $i<j$ gives $\mu_{ij}=0$. Hence $\mathcal{S}$ is linearly independent.
There are $n$ diagonal basis elements and $\frac{n(n-1)}{2}$ pairs $(i,j)$ with $1\le i<j\le n$. Therefore
\begin{align*}
\dim_k S=n+\frac{n(n-1)}{2}=\frac{n(n+1)}{2}.
\end{align*}
[guided]
Recall that $S:=\{A\in M_n(k):A^\top=A\}$ is the symmetric subspace. The symmetric condition says that every entry below the diagonal is already determined by the corresponding entry above the diagonal. More precisely, for $A\in S$ we have $A^\top=A$, so the $(i,j)$-entry of $A^\top$ equals the $(i,j)$-entry of $A$. Since the $(i,j)$-entry of $A^\top$ is $A_{ji}$, this gives
\begin{align*}
A_{ji}=A_{ij}
\end{align*}
for all $1\le i,j\le n$.
Thus the independent parameters are the diagonal entries $A_{ii}$ and the strictly upper-triangular entries $A_{ij}$ with $i<j$. The diagonal entry $A_{ii}$ contributes the matrix unit $E_{ii}$. The off-diagonal parameter $A_{ij}$ with $i<j$ must place the same scalar in both the $(i,j)$-entry and the $(j,i)$-entry, so it contributes the symmetric matrix unit combination $E_{ij}+E_{ji}$. Therefore every $A\in S$ has the expansion
\begin{align*}
A=\sum_{i=1}^{n}A_{ii}E_{ii}+\sum_{1\le i<j\le n}A_{ij}(E_{ij}+E_{ji}).
\end{align*}
This proves spanning.
To prove [linear independence](/page/Linear%20Independence), suppose a linear combination of these proposed basis elements is zero:
\begin{align*}
\sum_{i=1}^{n}\lambda_iE_{ii}+\sum_{1\le i<j\le n}\mu_{ij}(E_{ij}+E_{ji})=0.
\end{align*}
The diagonal entry in position $(i,i)$ of this matrix is exactly $\lambda_i$, so $\lambda_i=0$ for every $i$. For $i<j$, the $(i,j)$-entry of the same matrix is exactly $\mu_{ij}$, because no other proposed basis element contributes to the $(i,j)$-entry. Hence $\mu_{ij}=0$ for every $i<j$. All coefficients vanish, so the family is linearly independent.
Finally, there are $n$ diagonal entries and one independent off-diagonal parameter for each unordered pair of distinct indices. The number of such pairs is $\frac{n(n-1)}{2}$. Hence
\begin{align*}
\dim_k S=n+\frac{n(n-1)}{2}=\frac{n(n+1)}{2}.
\end{align*}
[/guided]
[/step]
[step:Use characteristic not equal to two to parametrize skew-symmetric matrices]
Assume $\operatorname{char}(k)\ne 2$. We claim that
\begin{align*}
\mathcal{K}:=\{E_{ij}-E_{ji}:1\le i<j\le n\}
\end{align*}
is a basis of $K$.
Let $A\in K$. Since $A^\top=-A$, we have $A_{ji}=-A_{ij}$ for all $i,j$. Taking $i=j$ gives $A_{ii}=-A_{ii}$, so $2A_{ii}=0$. Because $\operatorname{char}(k)\ne 2$, the scalar $2\in k$ is nonzero and hence invertible, so $A_{ii}=0$ for every $i$. Therefore
\begin{align*}
A=\sum_{1\le i<j\le n}A_{ij}(E_{ij}-E_{ji}).
\end{align*}
Thus $\mathcal{K}$ spans $K$.
If
\begin{align*}
\sum_{1\le i<j\le n}\nu_{ij}(E_{ij}-E_{ji})=0
\end{align*}
with $\nu_{ij}\in k$, then looking at the $(i,j)$-entry for each $i<j$ gives $\nu_{ij}=0$. Hence $\mathcal{K}$ is linearly independent.
There are $\frac{n(n-1)}{2}$ pairs $(i,j)$ with $1\le i<j\le n$, so
\begin{align*}
\dim_k K=\frac{n(n-1)}{2}.
\end{align*}
[/step]
[step:Collect the three dimension computations]
We have proved that the diagonal subspace $D$ has basis $\mathcal{D}$ and dimension $n$, the symmetric subspace $S$ has basis $\mathcal{S}$ and dimension $\frac{n(n+1)}{2}$, and, under the hypothesis $\operatorname{char}(k)\ne 2$, the skew-symmetric subspace $K$ has basis $\mathcal{K}$ and dimension $\frac{n(n-1)}{2}$. These are precisely the three asserted dimension formulas.
[/step]