Be careful: A homotopy equivalence is by no means a bijection in general: Let $X = \mathbb{R}$ and $Y = \{\ast\}$. Also, a homotopy equivalence need not restrict to a homotopy equivalence of subspaces. For instance, the orthogonal projection of $\mathbb{R}^2$ onto the $x$ axis is a homotopy equivalence. However, it maps the unit circle to the interval $[-1,1]$ and these two spaces certainly aren't homotopy equivalent (but this isn't completely obvious). Even simpler, take the subspace $([-1,1] \times \{0\}) \cup ([-1,1] \times \{1\})$ of $\mathbb{R}^2$ and its image $[-1,1]$ under the projection: you'll get a contradiction to your exercise.
The expressions $gf \simeq \operatorname{id}_{X}$ and $fg \simeq \operatorname{id}_{Y}$ mean that $gf$ and $fg$ are homotopic to the respective identities. (btw: it is more customary to use $\simeq$ \simeq
instead of $\cong$ for "homotopic")
A continuous map sends path components into path components (because it sends paths to paths). The path component of a point $x$ is sent into the path component of its image $f(x)$ and the path component of $f(x)$ is sent into the path component of $gf(x)$. But as $gf \simeq \operatorname{id}_{X}$, a homotopy $H: X \times [0,1] \to X$ such that $H(\cdot,0) = gf$ and $H(\cdot,1) = \operatorname{id}_{X}$ gives us the path $\gamma(t) = H(x,t)$ connecting $gf(x)$ with $x$, so the path component of $gf(x)$ is the same as the path component of $x$. I let you finish up the argument yourself.
Added in response to the edited question.
Let $[x]$ be the path component of $x$. Let me write $f_{\ast}: \pi_{0}(X) \to \pi_{0}(Y)$ instead of $f^\ast$. By definition $f_{\ast}[x] = [f(x)]$ (check that this is well-defined!). In my last paragraph above I argued that $[gf(x)] = [x]$ so $g_\ast f_\ast [x] = [x]$ (check that $(gf)_\ast = g_\ast f_\ast$!). In other words $g_\ast f_\ast = (\operatorname{id}_{X})_{\ast} = \operatorname{id}_{\pi_{0}(X)}$ (check that $(\operatorname{id}_X)_\ast = \operatorname{id}_{\pi_{0}(X)}$!). In particular, $f_{\ast}$ is injective and $g_\ast$ is surjective. By symmetry we have $f_\ast g_\ast = \operatorname{id}_{\pi_{0}(Y)}$, so $f_{\ast}$ and $g_\ast$ are mutually inverse bijections.
A bit later
Maybe it's better to start from scratch.
Define an equivalence relation on $X$ by x \sim x' if and only if there is a path connecting $x$ and x'. The equivalence classes of $\sim$ are precisely the path components of $X$. In other words, $\pi_{0}(X) = X/\!\!\sim$. Write $[x]$ for the $\sim$-equivalence class of $x$ (so $[x]$ is the path component of $x$).
Fact 1: A continuous map $f: X \to Y$ sends path components into path components. In other words, if $x \sim x$ then f(x) \sim f(x').
Indeed, if $\gamma: [0,1] \to X$ is a path with $\gamma(0) = x$ and \gamma(1) = x' then $f \circ \gamma: [0,1] \to Y$ is a path and $f(\gamma(0)) = f(x)$ and f(\gamma(1)) = f(x'), so f(x) \sim f(x').
Again in other words Fact 1 tells us that $f$ yields a map $f_{\ast}: \pi_{0}(X) \to \pi_{0}(Y)$. Explicitly, \[ f_{\ast}([x]) = [f(x)]. \] This is well-defined because for x \sim x' we have f(x) \sim f(x'), so [f(x)] = [f(x')].
From this description we see that $(\operatorname{id}_{X})_{\ast}([x]) = [\operatorname{id}_{X}(x)] = [x] = \operatorname{id}_{\pi_{0}(X)}([x])$, so $(\operatorname{id}_{X})_{\ast} = \operatorname{id}_{\pi_{0}(X)}$. Also $(gf)_{\ast}([x]) = [gf(x)] = g_{\ast}([f(x)]) = g_{\ast}f_{\ast}([x])$, so $(gf)_{\ast} = g_{\ast}f_{\ast}$.
Since the two identities I've just proven are so important, let me state them again for emphasis:
Fact 2: For the identity $\operatorname{id}_{X}: X \to X$ and any two maps $f:X \to Y$ and $g: Y \to Z$ we have $\displaystyle (\operatorname{id}_{X})_{\ast} = \operatorname{id}_{\pi_{0}(X)}: \pi_{0}(X) \to \pi_{0}(X) \qquad\text{and}\qquad (gf)_{\ast} = g_\ast f_\ast : \pi_{0}(X) \to \pi_{0}(Z) $
Fact 3: If f, f': X \to Y are homotopic, f \simeq f', then f_{\ast} = f'_{\ast}: \pi_{0}(X) \to \pi_{0}(Y).
Indeed, pick a homotopy $H: X \times [0,1] \to Y$ such that $f = H(\cdot,0)$ and f' = H(\cdot,1). Since $t \mapsto H(x,t)$ is a path connecting $f(x)$ to f'(x) we see that f(x) \sim f'(x), so f_{\ast}[x] = [f(x)] = [f'(x)] = f'_\ast[x].
Now we are finally in shape to solve the exercise. Let $f: X \to Y$ and $g: Y \to X$ be such that $gf \simeq \operatorname{id}_{X}$ and $fg \simeq \operatorname{id}_{Y}$. Then combining facts 2 and 3 we have that $\displaystyle (\operatorname{id}_{X})_\ast = g_{\ast} f_{\ast} \qquad \text{and}\qquad (\operatorname{id}_{Y})_\ast = f_{\ast} g_{\ast} $ and as $(\operatorname{id}_X)_\ast = \operatorname{id}_{\pi_{0}(X)}$ we see that $f_{\ast}$ and $g_{\ast}$ are mutually inverse bijections.