[proofplan]
We realise all pullback bundles as fibre products and compare their elements directly. The proposed map forgets the redundant middle point $y=f(x)$, and its inverse reinstates that point. We then check that the maps preserve the bundle projections and are smooth by writing them in local bundle trivializations, where both pullback bundles become the same product bundle over the same open subset of $M$. The identity-map case is the same fibre-product identification with no middle map.
[/proofplan]
[step:Realise the two iterated pullbacks as fibre products]
Let
\begin{align*}
\rho_N:g^*E\to N
\end{align*}
denote the pullback bundle projection, where
\begin{align*}
g^*E=\{(y,e)\in N\times E: g(y)=\pi(e)\},
\qquad
\rho_N(y,e)=y.
\end{align*}
Then the pullback of $\rho_N:g^*E\to N$ along $f:M\to N$ is
\begin{align*}
f^*(g^*E)
=
\{(x,(y,e))\in M\times g^*E: f(x)=y\}.
\end{align*}
Unpacking the condition $(y,e)\in g^*E$, an element of $f^*(g^*E)$ is precisely a triple $(x,(y,e))$ such that
\begin{align*}
f(x)=y,
\qquad
g(y)=\pi(e).
\end{align*}
Substituting $y=f(x)$ gives
\begin{align*}
\pi(e)=g(f(x))=(g\circ f)(x).
\end{align*}
Thus the same data determine an element of
\begin{align*}
(g\circ f)^*E
=
\{(x,e)\in M\times E:(g\circ f)(x)=\pi(e)\}.
\end{align*}
[/step]
[step:Construct mutually inverse bundle maps over $M$]
Define the map $\Phi:f^*(g^*E)\to (g\circ f)^*E$ by sending each element $(x,(y,e))$ to $(x,e)$.
This is well-defined because, for every $(x,(y,e))\in f^*(g^*E)$, the equalities $y=f(x)$ and $g(y)=\pi(e)$ imply $(g\circ f)(x)=\pi(e)$.
Define the map $\Psi:(g\circ f)^*E\to f^*(g^*E)$ by sending each element $(x,e)$ to $(x,(f(x),e))$.
This is well-defined because if $(x,e)\in (g\circ f)^*E$, then $\pi(e)=g(f(x))$, so $(f(x),e)\in g^*E$, and the defining relation for $f^*(g^*E)$ is satisfied:
\begin{align*}
f(x)=f(x).
\end{align*}
For every $(x,(y,e))\in f^*(g^*E)$, the condition $y=f(x)$ gives
\begin{align*}
(\Psi\circ\Phi)(x,(y,e))
=
\Psi(x,e)
=
(x,(f(x),e))
=
(x,(y,e)).
\end{align*}
For every $(x,e)\in (g\circ f)^*E$,
\begin{align*}
(\Phi\circ\Psi)(x,e)
=
\Phi(x,(f(x),e))
=
(x,e).
\end{align*}
Hence $\Phi$ and $\Psi$ are inverse bijections.
Let
\begin{align*}
\rho_M:f^*(g^*E)\to M,
\qquad
\rho_M(x,(y,e))=x,
\end{align*}
and let
\begin{align*}
\sigma_M:(g\circ f)^*E\to M,
\qquad
\sigma_M(x,e)=x,
\end{align*}
be the bundle projections. Then
\begin{align*}
\sigma_M(\Phi(x,(y,e)))=\sigma_M(x,e)=x=\rho_M(x,(y,e)),
\end{align*}
so $\Phi$ is a map over $M$. The same calculation shows that $\Psi$ is a map over $M$.
[/step]
[step:Check smoothness in local bundle trivializations]
Fix $x_0\in M$, and set $p_0=(g\circ f)(x_0)\in P$. Choose an open neighbourhood $V\subset P$ of $p_0$, a smooth manifold $F$, and a local bundle trivialization
\begin{align*}
\theta:\pi^{-1}(V)&\to V\times F
\end{align*}
for $\pi:E\to P$, so that the first component of $\theta(e)$ is $\pi(e)$ for every $e\in \pi^{-1}(V)$. Define the open subset
\begin{align*}
U:=(g\circ f)^{-1}(V)\subset M.
\end{align*}
Write
\begin{align*}
\theta(e)=(\pi(e),a)
\end{align*}
with $a\in F$. The trivialization of $(g\circ f)^*E$ over $U$ induced by $\theta$ is the map $\Theta_2:\sigma_M^{-1}(U)\to U\times F$ sending $(x,e)$ to $(x,a)$, where $\theta(e)=((g\circ f)(x),a)$. The corresponding trivialization of $f^*(g^*E)$ over $U$ is the map $\Theta_1:\rho_M^{-1}(U)\to U\times F$ sending $(x,(y,e))$ to $(x,a)$, where $y=f(x)$ and $\theta(e)=(g(y),a)$.
In these local coordinates,
\begin{align*}
(\Theta_2\circ\Phi\circ\Theta_1^{-1})(x,a)=(x,a)
\end{align*}
for every $(x,a)\in U\times F$. Thus $\Phi$ is locally represented by the identity map on $U\times F$, hence is smooth. Similarly,
\begin{align*}
(\Theta_1\circ\Psi\circ\Theta_2^{-1})(x,a)=(x,a),
\end{align*}
so $\Psi$ is smooth.
[guided]
The only point not settled by the fibrewise formula is smoothness. We verify it by reducing the maps to a calculation in local product coordinates.
Fix a point $x_0\in M$ and define $p_0=(g\circ f)(x_0)\in P$. Since $\pi:E\to P$ is a smooth fibre bundle, there exist an open neighbourhood $V\subset P$ of $p_0$, a smooth manifold $F$, and a smooth bundle trivialization
\begin{align*}
\theta:\pi^{-1}(V)&\to V\times F.
\end{align*}
This means that if $\theta(e)=(p,a)$, then $p=\pi(e)$. Now define
\begin{align*}
U:=(g\circ f)^{-1}(V)\subset M.
\end{align*}
Because $g\circ f:M\to P$ is smooth and $V$ is open, $U$ is open in $M$.
On the pullback bundle $(g\circ f)^*E$, the trivialization induced by $\theta$ is the map $\Theta_2:\sigma_M^{-1}(U)\to U\times F$ sending $(x,e)$ to $(x,a)$, where $\theta(e)=((g\circ f)(x),a)$. On the iterated pullback $f^*(g^*E)$, the corresponding trivialization is the map $\Theta_1:\rho_M^{-1}(U)\to U\times F$ sending $(x,(y,e))$ to $(x,a)$, where $y=f(x)$ and $\theta(e)=(g(y),a)$. Since $y=f(x)$, the first coordinate $g(y)$ is exactly $(g\circ f)(x)$, so both trivializations use the same fibre coordinate $a\in F$.
Now compute the coordinate expression of $\Phi$. Starting from $(x,a)\in U\times F$, the inverse chart $\Theta_1^{-1}$ gives the unique point $(x,(f(x),e))$ with
\begin{align*}
\theta(e)=((g\circ f)(x),a).
\end{align*}
Applying $\Phi$ gives $(x,e)$, and applying $\Theta_2$ sends this back to $(x,a)$. Hence
\begin{align*}
(\Theta_2\circ\Phi\circ\Theta_1^{-1})(x,a)=(x,a).
\end{align*}
Thus, in local coordinates, $\Phi$ is the identity map on $U\times F$, so $\Phi$ is smooth. The same calculation for the inverse map gives
\begin{align*}
(\Theta_1\circ\Psi\circ\Theta_2^{-1})(x,a)=(x,a),
\end{align*}
so $\Psi$ is smooth as well.
[/guided]
[/step]
[step:Conclude the canonical isomorphism and handle the identity map]
The previous steps show that $\Phi$ is a smooth bundle map over $M$ with smooth inverse $\Psi$. Therefore $\Phi$ is a smooth bundle isomorphism
\begin{align*}
f^*(g^*E)\cong (g\circ f)^*E
\end{align*}
over $M$.
For the identity statement, let $\pi:E\to N$ be a smooth fibre bundle. The pullback along $\operatorname{id}_N:N\to N$ is
\begin{align*}
\operatorname{id}_N^*E
=
\{(x,e)\in N\times E:x=\pi(e)\}.
\end{align*}
Define $A:\operatorname{id}_N^*E\to E$ by sending $(x,e)$ to $e$, and define $B:E\to \operatorname{id}_N^*E$ by sending $e$ to $(\pi(e),e)$.
The defining condition for $\operatorname{id}_N^*E$ makes both maps well-defined, and
\begin{align*}
(A\circ B)(e)=e,
\qquad
(B\circ A)(x,e)=(\pi(e),e)=(x,e).
\end{align*}
Both maps preserve the projections to $N$, because $\pi(A(x,e))=\pi(e)=x$. In any local trivialization of $E$ over an [open set](/page/Open%20Set) $V\subset N$, the coordinate expressions of $A$ and $B$ are the identity maps on $V\times F$. Hence $A$ is a smooth bundle isomorphism over $N$. This proves the canonical identification $\operatorname{id}_N^*E\cong E$.
[/step]