En Passant

It is helpful to know why the rule was created. It was created when it was decided that pawns can move two squares on their first move. At the same time the ”en passant” rule was put in place so that the creation of passed pawns would not become too easy.
So the ”en passant” is firmly linked to the opponent pawns first move when it advances two squares. The capture of that pawn happens exactly like it would, had it only moved one square. So if you are white and have a pawn on the 5th rank and your opponent moves their pawn from the 7th rank to the 5th right next to your pawn, you may capture that pawn moving your pawn diagonally to the 6th rank and onto the same file the opponent pawn was on.
The move can only be played right after the opponent made their 2 square pawn leap. If you make another move first you can not capture that pawn en passant anymore. En passant is not mandatory, so when it is not useful, you do not have to do it.
Hope that helps.
I think there is a lesson on it here on chess.com also so check that out if you need further instruction.