To see that $f$ is injective, let $m, n \in \mathbb{Z}$ and assume that $f(m) = f(n)$. If this common value of $f(m)$ and $f(n)$ is even, then $m,n \ge 0$, so $2m = 2n$, and therefore $m = n$. If the common value of $f(m)$ and $f(n)$ is odd, then $m,n \lt 0$, so $-2m - 1 = -2n - 1$, so $-2m = -2n$, and again we have $m = n$.
To see that $f$ is surjective, let $r \in \mathbb{N}$. If $r$ is even, say $r = 2n$ where $n \ge 0$, then $f(n) = r$. If $r$ is odd, say $r = 2n-1$ where $n \gt 0$, then $-n \lt 0$ and we can compute $f(-n) = r$. In both cases we showed that $r$ is in the range of $f$.