This is part 2 of the question I asked here. Can you tell me if this proof is correct? I thought it's better to ask this in a new separate question, the old post was getting a bit long. Many thanks for your help!
Claim: $f$ restricts to a homotopy equivalence from each path-component of $X$ to the corresponding path-component of $Y$.
Proof:
Let $A \in \pi_0(X)$. I claim that $f|_A : A \rightarrow f(A)$ is a homotopy equivalence with $g|_{f(A)}$ such that $f|_A \circ g|_{f(A)} \simeq id_{f(A)}$ and $g|_{f(A)} \circ f|_A \simeq id_A$, given homotopies $$ h:[0,1] \times X \rightarrow Y , h(0, ) = g \circ f, h(1, ) = id_X$$ $$ \tilde{h}:[0,1] \times Y \rightarrow X , h(0, ) = f \circ g, g(1, ) = id_Y$$
(i) $ g|_{f(A)} \circ f|_A \simeq id_A$:
Then $h^\prime := h|_A$ is a homotopy from $g|_{f(A)} \circ f|_A$ to $id_A$: $$ h^\prime(0, ) = h(0, )|_A = g \circ f|_A = g|_{f(A)} \circ f|_A$$ and $$ h^\prime(1, ) = h(1, )|_A = id_A$$
(ii) $f|_A \circ g|_{f(A)} \simeq id_{f(A)}$:
$h^{\prime \prime} := \tilde{h}|_{f(A)}$ is a homotopy from $f|_A \circ g|_{f(A)}$ to $id_{f(A)}$: $$ h^{\prime \prime}(0, )= \tilde{h}(0, )|_{f(A)} = f\circ g|_{f(A)}$$
But $f \circ g|_{f(A)} = f|_A \circ g|_{f(A)}$ because $A$ is a maximal path-connected subset of $X$ and $f,g$ are continuous so $f(A)$ is a maximal path-connected subset of $Y$. If there was a point $f(y) \in f(A)$ such that there is no path from $x$ to $y$ in $A$, this would cause a contradiction so $g(f(A)) \subset A$ and therefore $$ f(g(f(A))) \subset f(A)$$ or $$ f \circ g|_{f(A)} = f|_A \circ g|_{f(A)}$$