Understanding properties of a matrix $A\in \mathcal{M}_n({K})$ for which $C(A)=\{f(A): f(x) \in K[x]\}$. Consider the set of all square matrices with $n$ columns over $K(\Bbb{R} \text{ or} \Bbb{C})$: $\mathcal{M}_n({K}) $
Define $Z(\mathcal{M}_n({K})) = \{A\in  \mathcal{M}_n({K}) : AB=BA, \forall B \in \mathcal{M}_n({K}) \}$
$C(A) =\{B\in \mathcal{M}_n({K}): AB=BA  \}$
Then $Z(\mathcal{M}_n({K}))=\{cI_n : c\in K\}$
For any $A\in \mathcal{M}_n({K})$,
$Z(\mathcal{M}_n({K}))\subset C(A) $
Again $\{f(A): f(x) \in K[x]\}\subset C(A) $
In fact any scalar matrix $cI_n$ is also a polynomial in $A$ i.e $f(A) =cI_n $ where $f\in K[x]$ is the constant polynomial $f(x) =c, c\in K$
Now I am interested in those $A\in \mathcal{M}_n({K})$ for which $C(A)=\{f(A): f(x) \in K[x]\}$
I want to study all properties of such matrix $A$

*

*Minimal polynomial of $A$


*Characteristics polynomial of $A$


*Diagonalizability of $A$


*Nilpotency of $A$


*If $B$ is another such matrix then the simultaneous diagonalizability of $A$ and $B$


*unitarily diagonalizability of $A$ and $B$.
Lastly if $$C(A) =\{f(A): f(x) \in K[x] \text{ irreducible} \}$$, then what are some interesting properties of $A$?
 A: The matrices satisfying your equality are perfectly known. There are matrices representing  the so-called cyclic endomorphisms.
Keywords. companion matrix, cyclic endomorphism.
Notation. if $M$ is a square matrix, $\mu_M$ will denote its minimal polynomial, ans $\chi_M$ will denote its characteristic polynomial.
Definition. If $f=c_0 + c_1 t + \cdots + c_{n-1}X^{n-1} + X^n \in K[X],$, the companion matrix $C_f$ wrt to
$f$ is the $n\times n$ matrix defined as
$$C_f =\begin{pmatrix}
0 & 0 & \dots & 0 & -c_0 \\
1 & 0 & \dots & 0 & -c_1 \\
0 & 1 & \dots & 0 & -c_2 \\
\vdots & \vdots & \ddots & \vdots & \vdots \\
0 & 0 & \dots & 1 & -c_{n-1}
\end{pmatrix}.$$
One may show that $\mu_{C_f}=\chi_{C_f}=f$.
More generally, the following properties are equivalent:
Thm. Let $A\in M_n(K)$ ($K$ arbitrary field). The following properties are equivalent:
$(1)$ $\mu_M=\chi_M$
$(2)$ $M$ is similar to a companion matrix. In this case $M$ is similar to $C_f$ with $f=\chi_M$.
$(3)$ there exists $v\in K^n$ such that $(v, Mv,\ldots,M^{n-1}v)$ is a $K$-basis of $K^n$
$(4)$ $C(M)=\{f(M): f\in K[X]\}$.
All these equivalences maybe found on in a good linear algebra book ore on the web.
The following corollary is then clear:
Corollary. Assume that $C(A)=\{ f(A): f\in K[X]\}$ ($K$ arbitrary field). Then:
$(1)$ $A$ is diagonalisable if and only if $\chi_A$ splits into in $K[X]$ with no multiple roots
$(2)$ $A$ is nilpotent if and only if $\chi_A=X^n$ if and only if it is similar to $$\begin{pmatrix}
0 & 0 & \dots & 0 & 0 \\
1 & 0 & \dots & 0 & 0 \\
0 & 1 & \dots & 0 & 0 \\
\vdots & \vdots & \ddots & \vdots & \vdots \\
0 & 0 & \dots & 1 & 0
\end{pmatrix}.$$ In this case, its nilpotency order is exactly $n$.
For the very last question,  since $\{ f(A), f\in K[X]\}\subset C(A)$ for all $A$, the equality $\{ f(A), f\in K[X] \mbox{ irreducible}\}= C(A)$ implies
$\{ f(A), f\in K[X] \mbox{ irreducible}\}= C(A)=\{ f(A), f\in K[X]\}.$
In particular, by the previous thm, $\mu_A=\chi_A$, so the degree of the minimal polynomial is exactly $n$.
For $K=\mathbb{C}$ irreducible polynomial have degree $1$. Now $A^2\in C(A)$, so $A^2=f(A)$ for some polynomial of degree $1$. Hence $A$ is annihilated by $X^2-f$ which has degree $2$. Since $\mu_A\mid X^2-f$, $\mu_A$ has degree $\leq 2$ , so $n\leq 2$.
Conversely, if $n=1,2$ and $A$ satisfies $\mu_A=\chi_A$, then  $\{ f(A), f\in K[X] \mbox{ irreducible}\}= C(A)$ holds.
For $K=\mathbb{R}$, the same reasoning shows that $\mu_A=\chi_A$ and that $n=1,2$ or $3$. It remains to inspect the case $n=3$, but i have no time for the moment.
A: I'll deal with the complex case to avoid issues with eigenvalues.

A matrix $A$ satisfies $$\tag1 C(A)=\{f(A): f(x) \in K[x]\}$$ if and only if $A$ is diagonalizable, and all eigenvalues of $A$ have multiplicity $1$.

This makes the answers to all the questions above, trivial.
Because both sides in $(1)$ are invariant under similarity we may assume that $A$ is in Jordan form.
Note that $f(A)$ is obtained by applying $f$ to each Jordan block. If the same eigenvalue appears in two Jordan blocks, then
$$
\begin{bmatrix}J_n(\lambda)\\ & J_m(\lambda)\end{bmatrix}
\begin{bmatrix}1\\ & 2\end{bmatrix}
=\begin{bmatrix}1\\ & 2\end{bmatrix}
\begin{bmatrix}J_n(\lambda)\\ & J_m(\lambda)\end{bmatrix}
$$
and $\begin{bmatrix}1\\ & 2\end{bmatrix}$ cannot be obtained as $f(A)$ since both blocks will have $f(\lambda)$ in the diagonal. So, no eigenvalue is repeated. Using this one can deduce that any matrix that commutes with $A$ is block-diagonal with blocks the same size as those from $A$. That is,
$$
A=\begin{bmatrix}J_{n_1}(\lambda_1)\\ &\ddots\\ && J_{n_k}(\lambda_k)\end{bmatrix}
$$
and if $B$ commutes with $A$ then
$$
B=\begin{bmatrix}B_1\\ & \ddots\\ && B_k\end{bmatrix}.
$$
Moreover, $B_jJ_{n_j}(\lambda_j)=J_{n_j}(\lambda_j)B_j$. This forces $B_j$ to be upper triangular with constant diagonals (i.e., a Toeplitz matrix). If the size of the block is 2 or more, it then easy to choose $B_j$ that is not of the form $f(J_{n_j}(\lambda_j))$. In the end, each Jordan block of $A$ has to be one-dimensional, so $A$ is diagonal with all its eigenvalues distinct.
Conversely, if $A$ is diagonalizable with distinct eigenvalues it is easy to check that any $B$ that commutes with $A$ is diagonal. As the eigenvalues of $A$ are distinct, it is always possible to find a polynomial $f$ with $B=f(A)$.
