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.
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|$.