As pointed out, there are many simultaneously diagonalizable matrices such that neither is a polynomial of the other. One example that comes to mind is
$$
A = \begin{bmatrix}1 & 0 & 0\\0 &1 & 0 \\0 & 0 & 2 \end{bmatrix},\quad \begin{bmatrix}1 & 0 & 0\\0 &2 & 0 \\0 & 0 & 2\end{bmatrix}
$$
since no polynomial in $A$ can make the topmost two diagonal entries unequal, and no polynomial in $B$ can make the bottommost two diagonal entries unequal.
However, if one matrix is a polynomial of the other, say
$$
B = a_nA^n + \cdots + a_1A + a_0I
$$
and $A$ is diagonalisable (say $A = PDP^{-1}$, with $D$ diagonal), then
$$
B = a_n(PDP^{-1})^n + \cdots + a_1PDP^{-1} + a_0I \\
= a_nPD^nP^{-1} + \cdots + a_1PDP^{-1} + a_0PIP^{-1}\\
= P(a_nD^n + \cdots + a_1D + a_0I)P^{-1} = PEP^{-1}
$$
where $E = a_nD^n + \cdots + a_1D + a_0I$ is diagonal. So $A$ and $B$ are simultaneously diagonalisable.