It is called en passant. It is a chess rule that exists for a long time. Here you go:
https://en.wikipedia.org/wiki/En_passant
Game recommended an illegal move


Most probably...
https://support.chess.com/article/683-what-is-en-passant
Day late and a dollar short again...

You're welcome.
That is certainly not why. Long time ago, pawns could only move 1 square up. Around 500 years ago, they wanted to speed up games, so pawns now could move 2 squares up from their starting position.
By doing that, it would be easier to make a passed pawn if not for en passant. You could just wait for the opponent to play let's say g4 and you just play h4 and that pawn is passed, can't be taken by another pawn. Because of this, there is en passant, so if you play h4 as the answer to g4, the opponent has the option, on the next move only, to take the pawn as if though the pawn was played on h3.
I thought pawns can only move diagonal when attacking.