Some flashlights have overly tight battery holders so the springs can't push the battery into contact all the time (my Thrunite TN4A is like this). If your light is like this, try pushing the battery so the positive end (or whichever end doesn't have a spring) is making contact.
Also, if these are primary cells (non rechargeable), did you check them with a voltmeter? Maybe you have a bad/dead one.
I'm not ashamed to say this, but usually when my light doesn't work after swapping batteries it is because I stuck at least one in backwards. Sometimes the corrosion from a leaked cell was keeping the conduit working, and every so often it's because of dirt or lint somewhere in the conductive portion of places like threads was the issue.
Once it was because one of the two new batteries was dead.