I am new to category theory.
I found the following definition.
An arrow $f:A\rightarrow B$ is called an isomorphism,
if there is an arrow $g:B\rightarrow A$ such that
$$
g\circ f=\mathrm{id}_A
$$
and
$$
f\circ g=\mathrm{id}_B .
$$
However, it seems clear to me that if $f:A\rightarrow B$ and $g:B\rightarrow A$ ,
then $g\circ f$ is identity and $f\circ g$ is identity,
because it is obvious that if you go from A to B and then from B to A, you go back to A.
So, my question is,
how can it be $f:A\rightarrow B$ and $g:B\rightarrow A$
but $g\circ f\ne \mathrm{id}_A$ or $f\circ g\ne\mathrm{id}_B$ ?
There can be many morphisms between objects. Consider $A=B=\mathbb{R}$. Then any two real functions can be composed in either order, but only special pairs are inverses of each other!