Solution to Abstract Algebra by Dummit & Foote 3rd edition Chapter 7.2 Exercise 7.2.7
Let $R$ be a commutative ring with 1. Prove that the center of the ring $M_n(R)$ is the set of scalar matrices.
Solution: Recall the definition and properties of $E_{i,j}$ from Exercise 7.2.6.
We begin with a lemma.
Lemma: $E_{p,q}E_{s,t} = E_{p,t}$ if $q = s$ and 0 otherwise.
Proof: If $q = s$, then the $p$-th row of $E_{p,q}E_{s,t}$ is the $s$-th row of $E_{s,t}$ and all other entries are 0. Thus $E_{p,q}E_{s,t} = E_{p,t}$. If $q \neq s$, then the $p$-th row of $E_{p,q}E_{s,t}$ is the $q$-th row of $E_{s,t}$, which is all zeroes, and all other entries are 0. Thus $E_{p,q}E_{s,t} = 0$. $\square$
Now suppose $B = [b_{i,j}] \in Z(M_n(R))$.
By Exercise 7.2.6, note that the $(p,t)$ entry of $$E_{p,q}BE_{s,t} = E_{p,q}E_{s,t}B is b_{q,s}.$$ By the lemma, if $q \neq s$, then $b_{q,s} = 0$. Thus $B$ is a diagonal matrix. Now if $q = s$, then the $(p,t)$ entry of $E_{p,t}B$ is $b_{q,q}$ on one hand, and $b_{t,t}$ on the other, since the $p$-th row of $E_{p,t}B$ is the $t$-th row of $B$. Thus $b_{q,q} = b_{t,t}$ for all choices of $q$ and $t$. Hence $B = bI$ for some $b \in R$, and we have $Z(M_n(R)) \subseteq \{ rI \ |\ r \in R \}$.
Conversely, $(rI)A = rA = Ar = A(rI)$. Thus $Z(M_n(R)) = \{ rI \ |\ r \in R \}$.