If $AB=BA$, prove that $ A=\begin{bmatrix} a & 0 \\ 0 & a \end{bmatrix} $

Let $A=\pmatrix{a&b\\c&d}$. For $B=\pmatrix{1&0\\0&0}$ we have $AB=\pmatrix{a&0\\c&0}$ and $BA=\pmatrix{a&b\\0&0}$. So $AB=BA$ implies $b=c=0$, that is $A=\pmatrix{a&0\\0&d}$. Now try, say $B=\pmatrix{0&1\\0&0}$.


Note: $$\begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix} \begin{pmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{pmatrix}= \begin{pmatrix} b_{11} & b_{12} \\ b_{21} & b_{22} \end{pmatrix} \begin{pmatrix} a_{11} & a_{12} \\ a_{21} & a_{22} \end{pmatrix} \Rightarrow \\ \begin{cases}\require{cancel}\cancel{a_{11}b_{11}}+a_{12}b_{21}=\cancel{b_{11}a_{11}}+b_{12}a_{21}\\ a_{11}b_{12}+a_{12}b_{22}=b_{11}a_{12}+b_{12}a_{22}\\ a_{21}b_{11}+a_{22}b_{21}=b_{21}a_{11}+b_{22}a_{21}\\ a_{21}b_{12}+\cancel{a_{22}b_{22}}=b_{21}a_{12}+\cancel{b_{22}a_{22}}\end{cases}$$ From $(1)$, since $b_{12}$ and $b_{21}$ can be any number, in particular, $b_{12}=0$ and $b_{21}\ne 0$, we get: $a_{12}=0$.

Similarly, for $b_{12}\ne 0$ and $b_{21}=0$, we get $a_{21}=0$.

From $(2)$, since $a_{12}=0$ and $b_{12}$ is an arbitrary number, we get $a_{11}b_{12}=b_{12}a_{22} \Rightarrow a_{11}=a_{22}$.