There are already several good answers to the question, but I think we can gain additional insight by considering the following closely related question:
Question: If $A\in M_n(R)$, where $M_n(R)$ is the ring of $n\times n$ matrices over the commutative ring $R$, and $p(x)=\det(x I-A)\in R[x]$ is the characteristic polynomial of $A$, why is
$$p(A)=\det(AI-A)=\det(A-A)=\det(0)=0\tag{1}$$
invalid, while on the other hand something like
$$p(0)=\det(0I-A)=\det(-A)=(-1)^n\det(A)\tag{2}$$
is valid?
Syntactically (1) and (2) are very similar, so the answer is not immediately obvious, and we must examine the semantics.
In both (1) and (2) we interpret the notation $p(s)$ to mean the result of substituting an element $s$ for the indeterminate $x$ in the polynomial $p(x)$. To make sense of this, we must recall the universal property of the polynomial ring $R[x]$:
Proposition: If $\varphi:R\to S$ is a ring homomorphism and $s\in S$ commutes with $\varphi(r)$ for every $r\in R$, then there is a unique homomorphism $\psi:R[x]\to S$ extending $\varphi$ with $\psi(x)=s$:
$\require{AMScd}$
\begin{CD}
R @>\subseteq >> R[x]\\
@V \varphi VV @VV \psi V\\
S @= S
\end{CD}
The homomorphism $\psi$ sends the polynomial $f(x)=r_0+r_1x+\cdots+r_kx^k$ to the element
$$\varphi(r_0)+\varphi(r_1)s+\cdots+\varphi(r_k)s^k\tag{3}$$
We call $\psi$ substitution (or evaluation) at $s$ relative to $\varphi$, and we write (3) as $f(s)$ when $\varphi$ is understood. (Note: the commutativity condition for $s$ is required since $x$ commutes with the elements of $R$ in $R[x]$ by construction.)
Back to the question: if $p(x)=c_0+c_1x+\cdots+c_nx^n$ is the characteristic polynomial of $A$, then in (1) we have, by (3),
$$p(A)=c_0I+c_1A+\cdots+c_nA^n\in M_n(R)\tag{4}$$
where in (3) we're using the homomorphism $\varphi:R\to M_n(R)$ given by $r\mapsto rI$, and the substitution is valid (homomorphic) since $A$ commutes with $rI$ for all $r\in R$.
On the other hand in (2) we have
$$p(0)=c_0+c_10+\cdots+c_n0^n\in R\tag{5}$$
where $\varphi$ is taken to be the identity homomorphism on $R$ in (3).
With these meanings clarified, it's evident that (1) is invalid, because the $p(A)$ on the left-hand side is a matrix in $M_n(R)$ by (4), while the $0$ on the right-hand side is a scalar in $R$, as other folks have already pointed out. However, this doesn't fully explain why (1) is invalid.
To see why (1) is invalid, it's helpful to first see why (2) is valid. On the left-hand side of the first equality in (2) we're substituting $0$ after computing a determinant in $R[x]$, as in (5), while on the right-hand side we're substituting $0$ before computing a determinant in $R$. Why do these agree?
Since the determinant is defined by the same formula regardless of the underlying (commutative) ring, it's a natural transformation, so it makes the following diagram commute:
$\require{AMScd}$
\begin{CD}
M_n(R[x]) @>\det_{R[x]} >> R[x]\\
@V M_n(\psi_0) VV @VV \psi_0 V\\
M_n(R) @>> \det_R> R\tag{6}
\end{CD}
In this diagram $\psi_0$ denotes substitution of $0$, and $M_n(\psi_0)$ denotes entrywise substitution of $0$. All the arrows are homomorphisms of the underlying multiplicative monoids of the rings. Starting with the matrix $xI-A$ at the top left and going right and then down, we obtain $p(0)$. Going down and then right, we obtain $\det(0I-A)$ -- crucially because in both $xI$ and $0I$ we're performing scalar multiplication, which is defined entrywise for matrices. So $p(0)=\det(0I-A)$ and (2) is valid.
What happens when we try to adapt this to (1)? Let $\psi_A:R[x]\to R[A]$ denote subsitution of $A$, where $R[A]$ is the (commutative!) subring of $M_n(R)$ generated by $A$ and the scalar matrices $rI$ for $r\in R$. Then the following diagram commutes:
$\require{AMScd}$
\begin{CD}
M_n(R[x]) @>\det_{R[x]} >> R[x]\\
@V M_n(\psi_A) VV @VV \psi_A V\\
M_n(R[A]) @>> \det_{R[A]}> R[A]\tag{7}
\end{CD}
Again starting with the matrix $xI-A$ at the top left of the diagram and going right and then down, we obtain $p(A)$. But going down and then right, we don't obtain $\det(AI-A)$, and there's no way we could.
To see why, note $M_n(R[A])$ consists of matrices of matrices (not to be confused with block matrices). For $B\in M_n(R[x])$, when we substitute $A$ for $x$ in the entries of $B$, we obtain a matrix each entry of which is a matrix in $R[A]$. If $B=(b_{ij}(x))$ where $b_{ij}(x)\in R[x]$ and $\Psi_A=M_n(\psi_A)$, then $\Psi_A(B)=(b_{ij}(A))$. In particular if $A=(a_{ij})$, then
$$\Psi_A(xI-A)=\Psi_A\begin{pmatrix}
x-a_{11}&\cdots&-a_{1n}\\
\vdots&\ddots&\vdots\\
-a_{n1}&\cdots&x-a_{nn}
\end{pmatrix}=\begin{pmatrix}
A-a_{11}I&\cdots&-a_{1n}I\\
\vdots&\ddots&\vdots\\
-a_{n1}I&\cdots&A-a_{nn}I
\end{pmatrix}\tag{8}$$
If we write $\mathbb{I}=\Psi_A(I)$ and $\mathbb{A}=\Psi_A(A)$, then
$$\Psi_A(xI-A)=A\mathbb{I}-\mathbb{A}\tag{9}$$
where $A\mathbb{I}$ denotes scalar multiplication (not matrix multiplication!) of the matrix $\mathbb{I}\in M_n(R[A])$ by the "scalar" (also a matrix) $A\in R[A]$. When we go down and right in the diagram (7), we obtain $\det(A\mathbb{I}-\mathbb{A})$, which is the matrix $p(A)$ in $R[A]$. The Cayley-Hamilton theorem says that this is the zero matrix:
$$p(A)=\det(A\mathbb{I}-\mathbb{A})=0\tag{10}$$
This analysis explains why (1) is invalid: the "substitution" of $A$ for $x$ in (1) to obtain $AI-A$ is semantically incorrect because it conflates scalar multiplication with matrix multiplication. It also provides the alternative (10) involving scalar multiplication which is valid for the same reason (2) is valid, namely that the determinant is a natural transformation.