I just cannot understand why definition of monomorphism is this:
$$ \forall g_{1}, g_{2} : f \circ g_{1} = f \circ g_{2} \Rightarrow g_{1}=g_{2} $$
if we consider injection as a special case of monomorphism we can simply build counterexample
Here we have two functions $g_1$ and $g_2$ that maps same set $c$ to $a$ differently, yet their composition with $f$ gives same results.
Meanwhile function $f$ is injective.
It is contradiction to what monomorphism definition says that for every possible pair of functions if their composition with $f$ equals, then those functions are equal, meanwhile they are not!
I find this definition to be accurate though:
$$ \text{ f is monomorphism} \iff \exists g_{1},g_{2},g_1\ne g_2 : f \circ g_1 = f \circ g_2 $$

Your function $f$ is not injective.
Notice that $f(x_1) = f(x_2)$ and yet $x_1≠x_2$.
Maybe I'm misinterpreting something.
The main idea behind how the definition of monomorphism abstracts the definition of injection, is by noticing that an element of a set can be considered as a map from a set containing only one element $1 := \{*\}$, (doesn't matter what $*$ is) to your set.
So for instance if you have the set $\{1,2\}$, there are exactly two maps from $1$ to it, namely the map that sends $*$ to $1$ and the map that sends $*$ to $2$.
With this idea in mind, the definition of injectivity is just that of monomorphism but for the domain of the variables equal to the set $1$.
Namely, $f : X → Y$ is injective iff $∀ x,y : 1 → X.\ f ◦ x = f ◦ y \Rightarrow x = y$.