Let $X,Y,Z$ be sets, let $f:X\to Y$, $g:Y \to Z$. If composition of $g\circ f$ is injective, the so is $f$.
This question has been asked many times: Show that if $g \circ f$ is injective, then so is $f$.
Composition of functions injective implies one of them is injective?
If g(f(x)) is one-to-one (injective) show f(x) is also one-to-one (given that...)
Every answer suggests a proof, where we argue by contrapostive and assume $x\neq x'$ is true and $f(x)=f(x')$ is true. Why is that so? I mean if the injectivity assumption is false, then we could also have the case where $x\neq x'$ is true but $f(x')$ is simply not defined. In this case the injectivity assumption is still false, just as the statement $x \neq x' \Rightarrow 3=5/0$ is false.