Definition.$\quad$ A mapping $\alpha\colon S\to T$ is said to be one-to-one or injective if $$x_1\neq x_2\quad\text{implies}\quad\alpha(x_1)\neq\alpha(x_2)\qquad(x_1,x_2\in S).$$
Here, the set $S$ is the domain and $T$ is the codomain. Because a statement and its contrapositive are equivalent, we see that claiming $\alpha\colon S\to T$ is injective is the same as showing that $\alpha(x_1)=\alpha(x_2)$ implies $x_1=x_2$, where $x_1,x_2\in S$.
In your problem, you have the mapping $f$ defined by $f(x)=2x$, but what are the domain and codomain? Presumably, your author is considering the mapping $f\colon\mathbb{Z}\to\mathbb{Z}$ defined by $f(x)=2x$, but you need to make sure the domain and codomain are clear at the outset. Otherwise, you cannot provide an adequate proof. That being said, what your author has done is essentially what I alluded to above; that is, he took the contrapositive of the given definition and is using that to show injectivity.
Since $f(x)=2x$, he considers the following, where $x_1$ and $x_2$ are presumed to be elements in $\mathbb{Z}$ (this is why it's important to specify your domain and codomain; otherwise, it's ambiguous):
$$
f(x_1)=f(x_2)\\[0.5em]
2x_1=2x_2\\[0.5em]
x_1=x_2.
$$
Hence, the mapping $f\colon\mathbb{Z}\to\mathbb{Z}$ defined by $f(x)=2x$ is injective.
Does this make more sense?