The move by black was the only thing preventing checkmate before. Black was in check and the pawn move triggering en passant blocked it. And white could always blunder and take with the bishop. A move that results in the other player having the ability to check you isn't illegal.
Maybe you're thinking that en passant is a forced move by white. It's not forced, it's just only available as a legal move the turn after the pawn move. For example, the black pawn moves like in the picture. You can't make another move, then black moves and then take the pawn with en passant.