I have started a question where I have to find the set $$\operatorname{Com}(A) = \{B \in M_2 \mid AB = BA\}$$
where $$A = \pmatrix{ 1 & 2 \\ 3 & 4}$$ I found this set, but now I am asked to show that $\operatorname{Com}(A)$ is a vector space and that $\{I, A\}$ is a basis of $\operatorname{Com}(A)$. And I have no idea to show this.
$\operatorname{Com}(A)$ is indeed a subspace of $M_2$. If two matrices $B$ and $B'$ commute with $A$, then their linear combination $\alpha B + \beta B'$ also commutes with $A$ for any scalars $\alpha, \beta$ as you can check.
Plugging in a generic $2\times 2$ matrix $B = \pmatrix{ b_{11} & b_{12} \\ b_{21} & b_{22}}$ yields
\begin{align} 0 &= AB - BA\\ &= \pmatrix{ 1 & 2 \\ 3 & 4}\pmatrix{ b_{11} & b_{12} \\ b_{21} & b_{22}}-\pmatrix{ b_{11} & b_{12} \\ b_{21} & b_{22}}\pmatrix{ 1 & 2 \\ 3 & 4}\\ &= \pmatrix{b_{11} + 2b_{21} & b_{12} + 2b_{22} \\ 3b_{11} + 4b_{21} & 3b_{12} + 4b_{22}}-\pmatrix{b_{11} + 3b_{12} & 2b_{11} + 4b_{12} \\ b_{21} + 3b_{22} & 2b_{21} + 4b_{22}}\\ &= \pmatrix{-3b_{12} + 2b_{21} & -2b_{11}-3b_{12} + 2b_{22} \\ 3b_{11} + 3b_{21}-3b_{22} & 3b_{12} - 2b_{21}} \end{align}
which gives a homogeneous linear system
$$ \left\{ \begin{array}{c} -3b_{12} + 2b_{21} = 0 \\ -2b_{11}-3b_{12} + 2b_{22}=0 \\ 3b_{11} + 3b_{21}-3b_{22} =0 \end{array} \right. $$
The solution space is $$\operatorname{span}\left\{\pmatrix{1 & 0 \\ 0 & 1}, \pmatrix{1 & 2 \\ 3 & 4}\right\} = \operatorname{span}\{I, A\}$$
so the linearly independent set $\{I, A\}$ is a basis for $\operatorname{Com}(A)$.
Note that this was not obvious from the definition of $\operatorname{Com}(A)$. In general $A$ can be a scalar multiple of $I$ so $\{I, A\}$ will not be linearly independent, or the dimension of the subspace can be $> 2$ so there will be other matrices in the basis.