The condition $A^3=P^3$ implies that $A$ and $P$ are both nonsingular or both singular.
If they are nonsingular, then $A^2P=AP^2$ implies that $A=P$ and you may write $\det(A^2+P^2)$ as $\det(2AP),\,2^n\det(A)^2,\,2^n\det(P)^2,\,\det(AP+PA)$ etc..
Now suppose they are singular. If $0$ is not a semisimple eigenvalue of $P$ (i.e. if its algebraic multiplicity and geometric multiplicity are different), then there exists some vector $x$ such that $Px\ne0$ but $P^2x=0$. So, from the two given conditions, we get $0\ne Px\in\ker(A^2)\cap\ker(P^2)$. Hence $\det(A^2+P^2)=0$.
If $0$ is a semisimple eigenvalue of $P$, then $\ker(P^2)=\ker(P^3)$. In turn, we have
$$
P^3\left(\ker(P^2)+\ker(A^2)\right)
=P^3\ker(A^2)
=A^3\ker(A^2)=0,
$$
so that $\ker(P^2)+\ker(A^2)\subseteq\ker(P^3)=\ker(P^2)$. Hence $\ker(A^2)\subseteq\ker(P^2)$. As $A$ is singular, we obtain $\ker(A^2)\cap\ker(P^2)=\ker(A^2)\ne0$. Hence $\det(A^2+P^2)=0$.