Doubt over the proof of Cayley- Hamilton heorem
$Q$ is in this proof the adjugate matrix of $P-\lambda I$, that is, the matrix transpose of the cofactor matrix of $P-\lambda I$. Each element of the cofactor matrix is $\pm$ the determinant of a sub-matrix of $P-\lambda I$, that is sum of products of $n-1$ elements of $P-\lambda I$, and more than one of the elements used in each of those determinant might contain a factor of $\lambda$.
So $k$, which is the greatest power of $\lambda$ appearing in $Q$, might be equal to $n$, but it also could be more or it could be less. Without proof, you can't simply say that $k=n$.
Try it for a $3\times 3$ identity matrix $A$ . The adj of $A-\lambda I$ is a diagonal matrix with entries $(1-\lambda)^2$ along the diagonal. That is of degree $2$ in $\lambda$, not degree $3$.
If $Q(\lambda)$ is the adjoint of $P-\lambda I$, by definition $Q(\lambda)(P-\lambda I)=det(P-\lambda I) I$.
Compare the maximum degree element of each matrix of the equality. If an element $q_{i,j}$ of $Q(\lambda)$ had degree $k$, then element in each diagonal element of the matrix would have max degree element would have degree $k+1$. You can prove it writing down the product on the left. So $n=k+1$.