Proving that the fundamental groups of two spaces with same homotopy type are isomorphic I'm new at algebraic topology and I'm working on proving the following theorem
Theorem. Let $(X, x_0)$ and $(Y, y_0)$ two pointed topological spaces such that there exist two continuous pointed maps $f : (X, x_0) \to (Y, y_0)$ and $g : (Y, y_0) \to (X, x_0)$ such that $g \circ f$ and the identity $id_X$ are homotopic, and $f \circ g$ and the identity $id_Y$ are homotopic. So, the maps
$$
    \begin{array}{ccccc}
        f_{\ast} & : & \pi_1(X, x_0) & \longrightarrow & \pi_1(Y, y_0) \\
        & & [\gamma] & \longmapsto & [f \circ \gamma]
    \end{array}
$$
and
$$
    \begin{array}{ccccc}
        g_{\ast} & : & \pi_1(Y, y_0) & \longrightarrow & \pi_1(X, x_0) \\
        & & [\sigma] & \longmapsto & [g \circ \sigma]
    \end{array}
$$
are isomorphisms.
To this end, we need the following proposition (which I managed to demonstrate)
Proposition. Let $X$ and $Y$ two topological spaces and $x_0 \in X$. Let $f_1 : X \to Y$ and $f_2 : X \to Y$ be two continuous homotopic maps via the map $h : X \times [0, 1] \to Y$. Let $\gamma : I \to Y$; $t \mapsto h(x_0, t)$. Then, for all loop $\delta : [0, 1] \to X$ based at $x_0$, we have
$$
    [\overline{\gamma} \ast (f_1 \circ \delta) \ast \gamma] = [f_2 \circ \delta] \in \pi_1(Y, f_2(x_0))
$$
where $\ast$ is the composition of paths, and $\overline{\gamma}$ is the inverse path of $\gamma$.
So here is the demonstration (and where I Will mention the step where I'm stuck)
Proof of the theorem. Let $h : X \times [0, 1] \to X$ the homotopy such that $h(x, 0) = x$ and $h(x, 1) = g \circ f (x)$, for all $x \in X$. Let $\gamma : [0, 1] \to X$, $t \mapsto h(x_0, t)$.
From the proposition above, we have
$$
    [\overline{\gamma} \ast \delta \ast \gamma] = [g \circ f \circ \delta] \in \pi_1(X, x_0)
$$
for all loop $\delta : [0,1] \to X$ based at $x_0$.
Note that $\gamma$ is a loop based on $x_0$: $\gamma(0) = h(x_0, 0) = x_0$ and $\gamma(1) = h(x_0, 1) = g(f(x_0)) = g(y_0) = x_0$. So we can write
$$
    [\overline{\gamma}] \ast [\delta] \ast [\gamma] = (g \circ f)_{\ast}([\delta]) \in \pi_1(X, x_0)
$$
This proves that $(g \circ f)_{\ast} = id_{\pi_1(X, x_0)}$ but I don't know why since composition of homotopy classes is not commutative.
(The end of the proof is pretty obvious by using the fact that $(g \circ f)_{\ast} = g_{\ast} \circ f_{\ast}$.)
Remark. I'm not actually searching for another proof of the isomorphism of $f_*$ and $g_*$, I'm just wondering why we deduced that $(g \circ f)_* = id_{\pi_1(X, x_0)}$ and any help or hint would be great.
Thanks in advance.
Best regards.
K. Y.
 A: It is not necessarily true that $(g \circ f)_* = id$. You have shown that $f_* \circ g_* = (g \circ f)_*$ is conjugation by some element $a \in \pi_1(X,x_0)$. This means that $f_* \circ g_*$ is an isomorphism which implies that $g_*$ is injective and $f_*$ is surjective. Similarly you see that $g_* \circ f_*$ is an isomorphism which implies that $f_*$ is injective and $g_*$ is surjective. Thus both $f_*, g_*$ are isomorphisms.
Remark:
If you know some category theory, then you see that the general pattern is this: You have morphisms $u : A \to B$ and $v : B \to A$ such that $i = v \circ u :A  \to A$ and $j = u \circ v : B \to B$ are isomorphisms. Then $u,v$ are isomorphisms (but $v \ne u^{-1}$ unless $i = id$).
To see this, note that $v \circ (u \circ i^{-1}) = id_A$ and $(j^{-1} \circ u) \circ v = id_B$, thus $j^{-1} \circ u = (j^{-1} \circ u) \circ id_A = (j^{-1} \circ u) \circ v \circ (u \circ i^{-1}) = id_B \circ (u \circ i^{-1}) = u \circ i^{-1}$. This shows that $v$ is an isomorphism with inverse $v^{-1} = j^{-1} \circ u = u \circ i^{-1}$. But then also $u = v^{-1} \circ i$ is an isomorphism with inverse $u^{-1} = i^{-1} \circ v = v \circ j^{-1}$.
