After diagonalizing, we may assume $A$ is a diagonal matrix. Thus, we may write it in the block diagonal form as $A = \bigoplus_{i=1}^m c_iI_{k_i}$ where $c_i \in \mathbb{C}$, $c_i \neq c_j$ whenever $i \neq j$, and $k_i$ are positive integers s.t. $\sum_{i=1}^m k_i = n$. Then the commutant of $A$ is $\{A\}’ = \bigoplus_{i=1}^m M_{k_i}(\mathbb{C})$, which can be verified by a direct calculation. Thus, as $X \in \{A\}’$ we must have $X_{kl} = 0$ whenever $k, l \in \{1, \cdots, n\}$ are in different blocks. As $X = AB - BA$ and $A$ is diagonal, we have, when $k, l \in \{1, \cdots, n\}$ are in different blocks,
$$0 = X_{kl} = (A_{kk} - A_{ll})B_{kl}$$
Since $k, l$ are in different blocks, $A_{kk} \neq A_{ll}$, whence $B_{kl} = 0$ whenever $k, l$ are in different blocks. But this means $B \in \bigoplus_{i=1}^m M_{k_i}(\mathbb{C}) = \{A\}’$, i.e., $A$ and $B$ commute, so $X = AB - BA = 0$.