There are some instances where it might seem like Magnus is making an illegal move, as shown in the illustration below. This is, in fact, a special rule called "en passant" that is allowed in all chess games.
You can read the official chess rules for en passant here:
https://en.wikipedia.org/wiki/En_passant