[proofplan]
We prove the two identities by checking them on representatives of de Rham cohomology classes. The identity map pulls every differential form back to itself, so it induces the identity on closed forms modulo exact forms. For composition, the pullback of differential forms satisfies $(\psi \circ \varphi)^*\omega = \varphi^*(\psi^*\omega)$ for every $k$-form $\omega$ on $P$; passing to cohomology preserves this equality because induced maps are defined by applying pullback to representatives.
[/proofplan]
[step:Recall the representative definition of the induced pullback map]
Let $X$ and $Y$ be smooth manifolds. For the smooth manifold $X$, let $\Omega^k(X)$ denote the [vector space](/page/Vector%20Space) of smooth differential $k$-forms on $X$. For each integer $r \geq 0$, let
\begin{align*}
d_X: \Omega^r(X) &\to \Omega^{r+1}(X)
\end{align*}
denote the [exterior derivative](/theorems/1525) on $X$; when the manifold is clear from context, we write $d$ for $d_X$. Define the space of closed $k$-forms by
\begin{align*}
Z^k(X) := \{\omega \in \Omega^k(X) : d\omega = 0\},
\end{align*}
and define the space of exact $k$-forms by
\begin{align*}
B^k(X) :=
\begin{cases}
d\Omega^{k-1}(X), & k \geq 1,\\
\{0\}, & k = 0.
\end{cases}
\end{align*}
Then
\begin{align*}
H^k_{\mathrm{dR}}(X) := Z^k(X) / B^k(X).
\end{align*}
If $f: X \to Y$ is a smooth map, its pullback on forms is the [linear map](/page/Linear%20Map)
\begin{align*}
f^*: \Omega^k(Y) &\to \Omega^k(X).
\end{align*}
By the naturality property recorded in the [exterior derivative](/page/Exterior%20Derivative) reference, pullback of differential forms commutes with the exterior derivative: for every $\eta \in \Omega^k(Y)$ one has $d_X(f^*\eta)=f^*(d_Y\eta)$. Therefore $f^*$ sends closed forms to closed forms and exact forms to exact forms. Hence it induces the map
\begin{align*}
f^*: H^k_{\mathrm{dR}}(Y) &\to H^k_{\mathrm{dR}}(X),\\
[\omega] &\mapsto [f^*\omega],
\end{align*}
where $\omega \in Z^k(Y)$ and $[\omega]$ denotes its cohomology class modulo $B^k(Y)$.
[guided]
We first fix exactly what the symbol $f^*$ means on cohomology. Let $X$ and $Y$ be smooth manifolds. For each integer $r \geq 0$, let
\begin{align*}
d_X: \Omega^r(X) &\to \Omega^{r+1}(X)
\end{align*}
denote the exterior derivative on $X$; when the manifold is clear from context, we write $d$ for $d_X$. For the smooth manifold $X$, the cohomology group $H^k_{\mathrm{dR}}(X)$ is not the space of all $k$-forms. It is the quotient of closed forms by exact forms. We write
\begin{align*}
Z^k(X) := \{\omega \in \Omega^k(X) : d\omega = 0\}
\end{align*}
for the closed forms and
\begin{align*}
B^k(X) :=
\begin{cases}
d\Omega^{k-1}(X), & k \geq 1,\\
\{0\}, & k = 0
\end{cases}
\end{align*}
for the exact forms. Thus
\begin{align*}
H^k_{\mathrm{dR}}(X) := Z^k(X) / B^k(X).
\end{align*}
Now let $f: X \to Y$ be a smooth map. Pullback of forms gives a linear map
\begin{align*}
f^*: \Omega^k(Y) \to \Omega^k(X).
\end{align*}
The reason this descends to cohomology is that pullback commutes with the exterior derivative. More precisely, by the naturality property recorded in the [exterior derivative](/page/Exterior%20Derivative) reference, for every $\eta \in \Omega^k(Y)$ one has $d_X(f^*\eta)=f^*(d_Y\eta)$, where $d_Y: \Omega^k(Y) \to \Omega^{k+1}(Y)$ is the exterior derivative on $Y$. If $\omega \in Z^k(Y)$, then
\begin{align*}
d(f^*\omega) = f^*(d\omega) = f^*0 = 0,
\end{align*}
so $f^*\omega \in Z^k(X)$. If $\omega \in B^k(Y)$ and $k \geq 1$, then there exists $\eta \in \Omega^{k-1}(Y)$ such that $\omega = d\eta$, and therefore
\begin{align*}
f^*\omega = f^*(d\eta) = d(f^*\eta) \in B^k(X).
\end{align*}
For $k = 0$, exact forms are $0$, and pullback sends $0$ to $0$. Therefore the representative formula
\begin{align*}
f^*: H^k_{\mathrm{dR}}(Y) &\to H^k_{\mathrm{dR}}(X),\\
[\omega] &\mapsto [f^*\omega]
\end{align*}
is well-defined.
[/guided]
[/step]
[step:Show that the identity map induces the identity on cohomology]
Let $\omega \in Z^k(M)$. The pullback of $\omega$ by the identity map $\operatorname{id}_M: M \to M$ is $\omega$ itself:
\begin{align*}
(\operatorname{id}_M)^*\omega = \omega.
\end{align*}
Therefore, by the definition of the induced map on cohomology,
\begin{align*}
(\operatorname{id}_M)^*[\omega] = [(\operatorname{id}_M)^*\omega] = [\omega].
\end{align*}
Since every element of $H^k_{\mathrm{dR}}(M)$ has the form $[\omega]$ for some $\omega \in Z^k(M)$, we obtain
\begin{align*}
(\operatorname{id}_M)^* = \operatorname{id}_{H^k_{\mathrm{dR}}(M)}.
\end{align*}
[/step]
[step:Show that pullback by a composition agrees with successive pullback]
Let $\omega \in Z^k(P)$. For every point $x \in M$ and tangent vectors $v_1, \dots, v_k \in T_xM$, the definition of pullback gives
\begin{align*}
((\psi \circ \varphi)^*\omega)_x(v_1,\dots,v_k)
&= \omega_{\psi(\varphi(x))}\bigl(d(\psi \circ \varphi)_x(v_1),\dots,d(\psi \circ \varphi)_x(v_k)\bigr).
\end{align*}
The differential of the composition satisfies
\begin{align*}
d(\psi \circ \varphi)_x = d\psi_{\varphi(x)} \circ d\varphi_x.
\end{align*}
Substituting this into the preceding formula gives
\begin{align*}
((\psi \circ \varphi)^*\omega)_x(v_1,\dots,v_k)
&= \omega_{\psi(\varphi(x))}\bigl(d\psi_{\varphi(x)}(d\varphi_x(v_1)),\dots,d\psi_{\varphi(x)}(d\varphi_x(v_k))\bigr)\\
&= (\psi^*\omega)_{\varphi(x)}\bigl(d\varphi_x(v_1),\dots,d\varphi_x(v_k)\bigr)\\
&= (\varphi^*(\psi^*\omega))_x(v_1,\dots,v_k).
\end{align*}
Since this equality holds at every $x \in M$ and on every $k$-tuple of tangent vectors in $T_xM$, we have
\begin{align*}
(\psi \circ \varphi)^*\omega = \varphi^*(\psi^*\omega)
\end{align*}
as elements of $\Omega^k(M)$.
[guided]
We now prove the form-level identity behind the cohomology-level identity. Let $\omega \in Z^k(P)$ be a closed $k$-form on $P$. We must compare two $k$-forms on $M$: the direct pullback $(\psi \circ \varphi)^*\omega$ and the successive pullback $\varphi^*(\psi^*\omega)$.
Fix a point $x \in M$ and tangent vectors $v_1,\dots,v_k \in T_xM$. By the definition of pullback of a $k$-form,
\begin{align*}
((\psi \circ \varphi)^*\omega)_x(v_1,\dots,v_k)
&= \omega_{\psi(\varphi(x))}\bigl(d(\psi \circ \varphi)_x(v_1),\dots,d(\psi \circ \varphi)_x(v_k)\bigr).
\end{align*}
The only differential-geometric input needed here is the compatibility of the differential with composition:
\begin{align*}
d(\psi \circ \varphi)_x = d\psi_{\varphi(x)} \circ d\varphi_x.
\end{align*}
Substituting this identity into each tangent-vector slot gives
\begin{align*}
((\psi \circ \varphi)^*\omega)_x(v_1,\dots,v_k)
&= \omega_{\psi(\varphi(x))}\bigl(d\psi_{\varphi(x)}(d\varphi_x(v_1)),\dots,d\psi_{\varphi(x)}(d\varphi_x(v_k))\bigr).
\end{align*}
Now apply the definition of $\psi^*\omega$ at the point $\varphi(x) \in N$ to the tangent vectors $d\varphi_x(v_1),\dots,d\varphi_x(v_k) \in T_{\varphi(x)}N$. This yields
\begin{align*}
\omega_{\psi(\varphi(x))}\bigl(d\psi_{\varphi(x)}(d\varphi_x(v_1)),\dots,d\psi_{\varphi(x)}(d\varphi_x(v_k))\bigr)
&= (\psi^*\omega)_{\varphi(x)}\bigl(d\varphi_x(v_1),\dots,d\varphi_x(v_k)\bigr).
\end{align*}
Finally, applying the definition of $\varphi^*$ to the $k$-form $\psi^*\omega \in \Omega^k(N)$ gives
\begin{align*}
(\psi^*\omega)_{\varphi(x)}\bigl(d\varphi_x(v_1),\dots,d\varphi_x(v_k)\bigr)
&= (\varphi^*(\psi^*\omega))_x(v_1,\dots,v_k).
\end{align*}
Thus
\begin{align*}
((\psi \circ \varphi)^*\omega)_x(v_1,\dots,v_k)
= (\varphi^*(\psi^*\omega))_x(v_1,\dots,v_k).
\end{align*}
Because $x$ and $v_1,\dots,v_k$ were arbitrary, the two $k$-forms are equal on $M$:
\begin{align*}
(\psi \circ \varphi)^*\omega = \varphi^*(\psi^*\omega).
\end{align*}
[/guided]
[/step]
[step:Pass the form-level composition identity to cohomology classes]
Let $[\omega] \in H^k_{\mathrm{dR}}(P)$ with representative $\omega \in Z^k(P)$. Using the representative definition of the induced pullback and the form-level composition identity, we compute
\begin{align*}
(\psi \circ \varphi)^*[\omega]
&= [(\psi \circ \varphi)^*\omega]\\
&= [\varphi^*(\psi^*\omega)]\\
&= \varphi^*[\psi^*\omega]\\
&= (\varphi^* \circ \psi^*)[\omega].
\end{align*}
Since every element of $H^k_{\mathrm{dR}}(P)$ is represented by some closed $k$-form $\omega \in Z^k(P)$, this proves
\begin{align*}
(\psi \circ \varphi)^* = \varphi^* \circ \psi^*
\end{align*}
as maps from $H^k_{\mathrm{dR}}(P)$ to $H^k_{\mathrm{dR}}(M)$.
[/step]
[step:Conclude contravariant functoriality]
The identity computation shows that the identity smooth map on $M$ induces the identity map on $H^k_{\mathrm{dR}}(M)$. The composition computation shows that pullback reverses composition:
\begin{align*}
(\psi \circ \varphi)^* = \varphi^* \circ \psi^*.
\end{align*}
Therefore, for every integer $k \geq 0$, de Rham cohomology is contravariantly functorial with respect to smooth maps.
[/step]