The exercise is to give an example for two sets $M$ and $N$, and functions $f$ and $g$, for which $f \circ g = id_M$, but $g \circ f \ne id_N$.
My idea is a bit based on my computer programming background, where (x/2)*2
is 0
for integers. Here it is:
$$M=N=\mathbb{N_0}.$$ $$f: \mathbb{N_0} \rightarrow \mathbb{N_0}, g: \mathbb{N_0} \rightarrow \mathbb{N_0}.$$ $$f(x) = 2x, g(x) = x \div 2.$$
Thus,
$$(g\circ f)(x) = g(f(x)) = g(2x) = 2x\div 2 = x = id_\mathbb{N_0}$$ $$(f\circ g)(x) = f(g(x)) = f(x\div2) = (x\div2)\cdot2 \ne id_\mathbb{N_0}$$
Because if $f(g(1)) = f(0) = (0\div 2)\cdot2 = 0$, and $0\ne 1$, it follows that $(f\circ g) \ne id_\mathbb{N_0}$
Is my example valid?