The most common cause of a lawn mower backfiring is a clogged carburetor.
The carburetor on the lawnmower has a tiny jet in it which can easily get clogged and when that tiny main jet gets clogged it does not allow enough or any fuel through it properly.
This can either cause the lawnmower engine to not run, run at choke or backfire and run poorly.
The fuel and air mixture get messed up when the fuel doesn't get into the engine properly.
Cleaning the carburetor by soaking it in some carburetor cleaner such as B12 chemtool for 30 minutes to an hour after taking it apart and blowing the main jet and other passages out can help fix the backfire and make your lawnmower engine run properly.
Also your spark plugs could be bad as well but it's most often the carburetor that is causing the issue with backfiring or running poorly.