Let $f: X\rightarrow Y$ and $g:Y\rightarrow X$ be functions such that $g(f(x))=x$ for all $x\in X$.
(a) Prove that $f$ is injective.
(b) Prove that $g$ is surjective.
(c) Give an example of a pair of functions $f:X\rightarrow Y$ and $g:Y\rightarrow X$ such that $g(f(x))=x$ and neither $f$ nor $g$ is bijective.
I know that $g(f(x))=x$ implies $g=f^{-1}$. If we know that $f$ has an inverse, does that automatically imply the function is injective and surjective? How?
If $f$ has an inverse, than this automatically implies that $f$ is injective and surjective: $f$ is injective because $f(x)=f(y)$ implies $x=y$, applying $f^{-1}$ to both sides. $f$ is surjective, because given any $y\in Y$ we have $f(f^{-1}(y))=y$. That is $f(X)=Y$.
But: Notice how we needed both equations, $f(f^{-1}(x))=x$ and $f^{-1}(f(x))$ in that deduction? If you have just $f(g(x))=x$ or $g(f(x))=x$, then this implies only that $f$ is surjective or injective, respectively. For bijectivity you need both equations!
Regarding your problems:
(a): Assume $f(x)=f(y)$. How can you show $x=y$?
(b): Let $x\in X$. How can you find $y\in Y$ such that $g(y)=x$?
(c): Let $X=\{0\}$, $Y=\mathbb{R}$, $f=g=0$. Then
$$g(f(0))=0$$
but clearly $f,g$ are not bijective.