This is with reference to the Proof of Cayley Hamilton theorem on Page 68 of Peter Lax Linear algebra and its application (second edition)
Equation 21 reads
According to formula 30 of Chapter 5
$$ P(s)Q(s) = det Q(s) I = P_A(s)I $$
Formula 30 in chapter 5 is actually the formula for the inverse of a matrix. So It is clear that $P(s)$ and $Q(s)$ are matrices whose elements are polynomials of $s$. Specifically, $P(s)$ is the matrix of cofactors of $Q(s)$
He goes on to invoke lemma 6 which states that
If P and Q are two polynomials with matrix coefficients...
So clearly the substitution is invalid, because in equation 21, $P(s)$ is a matrix whose elements are polynomials of $s$, whereas in Lemma 6, $P(s)$ is a polynomial of $s$ with matrix coefficients.
Am I misunderstanding something?
If $A_k=(a_{i,j}^{(k)})$ are matrices of the same size then
$$\sum_{k=0}^{n}A_ks^k=\left(\sum_{k=0}^na_{i,j}^{(k)}s^k\right)$$
The LHS is a polynomial with $A_k$ as coefficients and the RHS is a matrix with polynomial entries.