4. Given that $P$ is a point on the incircle of square $A B C D$, let $\angle A P C=\alpha, \angle B P D=\beta$, then $\tan ^{2} \alpha+\tan ^{2} \beta=$
Establish a coordinate system as shown in the figure. Let the side length of the square $ABCD$ be 2, then
$$
\begin{array}{l}
P(1+\cos \theta, 1+\sin \theta), \overrightarrow{P A}=(-1-\cos \theta,-1-\sin \theta), \\
\overrightarrow{P B}=(1-\cos \theta,-1-\sin \theta), \\
\overrightarrow{P C}=(1-\cos \theta, 1-\sin \theta), \\
\overrightarrow{P D}=(-1-\cos \theta, 1-\sin \theta) .
\end{array}
$$

Thus, $\overrightarrow{P A} \cdot \overrightarrow{P C}=-(1+\cos \theta)(1-\cos \theta)-(1+\sin \theta)(1-\sin \theta)=-1$,
$$
\begin{array}{l}
|\overrightarrow{P A}|^{2}=(1+\cos \theta)^{2}+(1+\sin \theta)^{2}=3+2(\cos \theta+\sin \theta), \\
|\overrightarrow{P C}|^{2}=(1-\cos \theta)^{2}+(1-\sin \theta)^{2}=3-2(\cos \theta+\sin \theta) \\
\Rightarrow|\overrightarrow{P A}| \cdot|\overrightarrow{P C}|=\sqrt{9-4(\cos \theta+\sin \theta)^{2}}=\sqrt{9-4(1+\sin 2 \theta)}=\sqrt{5-4 \sin 2 \theta} \\
\Rightarrow \cos \alpha=\frac{\overrightarrow{P A} \cdot \overrightarrow{P C}}{|\overrightarrow{P A}| \cdot|\overrightarrow{P C}|}=-\frac{1}{\sqrt{5-4 \sin 2 \theta}} \Rightarrow \tan ^{2} \alpha=4-4 \sin 2 \theta .
\end{array}
$$

Similarly, $\overrightarrow{P B} \cdot \overrightarrow{P D}=-(1+\cos \theta)(1-\cos \theta)-(1+\sin \theta)(1-\sin \theta)=-1$,
$$
\begin{array}{l}
|\overrightarrow{P B}|^{2}=(1-\cos \theta)^{2}+(1+\sin \theta)^{2}=3-2(\cos \theta-\sin \theta), \\
|\overrightarrow{P D}|^{2}=(1+\cos \theta)^{2}+(1-\sin \theta)^{2}=3+2(\cos \theta-\sin \theta) \\
\Rightarrow|\overrightarrow{P B}| \cdot|\overrightarrow{P D}|=\sqrt{9-4(\cos \theta-\sin \theta)^{2}}=\sqrt{9-4(1-\sin 2 \theta)}=\sqrt{5+4 \sin 2 \theta} \\
\Rightarrow \cos \beta=\frac{\overrightarrow{P B} \cdot \overrightarrow{P D}}{|\overrightarrow{P B}| \cdot|\overrightarrow{P D}|}=-\frac{1}{\sqrt{5+4 \sin 2 \theta}} \Rightarrow \tan ^{2} \beta=4+4 \sin 2 \theta .
\end{array}
$$

Therefore, $\tan ^{2} \alpha+\tan ^{2} \beta=8$.