In introducing the concept of $K(G, 1)$, Hatcher's Algebraic Topology proves the theorem that the homotopy type of a CW complex $K(G, 1)$ is uniquely determined by $G$, by citing a proposition and claiming the proposition may be used to deduce the theorem. I am wondering why the bolded statement is true here:
Proposition 1B.9. Let $X$ be a connected CW complex and let $Y$ be a $K(G, 1)$. Then every homomorphism $\pi_1(X, x_0) \to \pi_1(Y, y_0)$ is induced by a map $(X, x_0) \to (Y, y_0)$ that is unique up to homotopy fixing $x_0$.
To deduce the theorem from this, let $X$ and $Y$ be CW complex $K(G, 1)$’s with isomorphic fundamental groups. The proposition gives maps $f : (X, x_0) \to (Y, y_0)$ and $g : (Y, y0) \to (X, x0)$ inducing inverse isomorphisms $\pi_1(X, x_0) \cong \pi_1(Y, y_0)$. Then $fg$ and $gf$ induce the identity on $\pi_1$ and hence are homotopic to the identity maps.
I am aware that in general, a map inducing the identity on $\pi_1$ is not necessarily homotopic to the identity, so why in this context can this argument be made? I am specifically looking for a justification that one would be able to follow at this point in Hatcher's text.
This last claim is another application of Proposition 1B.9. By the proposition, there is a unique (up to homotopy) map $(X,x_0)\to (X,x_0)$ that induces the identity on $\pi_1$. One such map is the identity map, and another such map is $gf$, so they must be homotopic. Similarly $fg$ must be homotopic to the identity $(Y,y_0)\to (Y,y_0)$ since there is a unique (up to homotopy) such map that induces the identity on $\pi_1$.