How can $|\mathbb{N}| = |\mathbb{Z}|$? I have seen proofs of a bijection $f:\mathbb{N} \to \mathbb{Z}$ where
$$f(n) = \begin{cases}
    \frac{n}{2} & n\text{ is even} \\
    -\frac{n + 1}{2} & \text{else}
\end{cases}$$
This shows that $\mathbb{Z}$ is countably infinite, that is, $f$ is one-to-one. We can also see that $f$ is onto. Therefore $\mathbb{N}$ and $\mathbb{Z}$ have the same number of elements.
But at the same time, we have $\mathbb{N} \subseteq \mathbb{Z}$. To show $\mathbb{N}$ is a proper subset of $\mathbb{Z}$, it would suffice to show that $\mathbb{Z}$ contains at least one element that $\mathbb{N}$ does not. Notice $-1 \in \mathbb{Z}$ and $-1 \notin \mathbb{N}$, so $\mathbb{N} \subset \mathbb{Z}$ and thus $|\mathbb{N}| < |\mathbb{Z}|$.
I assume this has something to with the fact that these are infinite sets, but I still can't put my finger on exactly why this can happen. If I could have some help understanding why this can happen, that would be great.
 A: Let's consider an example that is a bit easier to deal with:
\begin{align}
A &= \{1,2,3,4,\dots\}, \\
B &= \{0,1,2,3,\dots\}.
\end{align}
It's easy to see that $A\subsetneq B$ and yet $A\to B, k \mapsto k-1$ is a bijection.
The conclusion that $|A|<|B|$ doesn't work for infinite sets, since there are always elements to "fill the gaps". In this example, removing $0$ from $B$ you get a gap at $0$, but $1$ can fill that gap. Now there's a gap at $1$, but $2$ can fill that gap, … Since this "gap filling process" never ends, there is no gap that can't be filled and we get $|A|=|B|$.
A: In fact,  it can be shown that for a set $S $, being infinite,  or of infinite cardinality,  is equivalent to the having the property of being in bijection with a proper subset $P\subsetneq S $.
Of special interest is the (Hilbert's hotel) shifting function, $f(x)=x+1$ from the whole numbers to the naturals.
A: 
Therefore $\mathbb{N}$ and $\mathbb{Z}$ have the same number of elements.

Wrong. They have the same cardinality. But it has nothing to do with the number of elements.
If we compare their numerocities, then $n(\mathbb{N})=\frac{n(\mathbb{Z})}2-\frac12$
