Sometimes there’s a little discrepancy between what users actually experience and what gets measured on a test fixture, mainly caused by how the headphones fit. A helpful user on Reddit explored this further and identified fit is indeed the culprit for many experiencing underwhelming results.
If you wear glasses, the arms of your specs can sometimes create a gap between the ear pad and your head, also making the ANC suffer. This is typical of any headphones, but something to be aware of.
If you find that your Sony WH-1000XM5 isn’t doing so hot where noise cancellation is concerned, it is almost assured that you have a bad fit. Before returning them, try moving the ear cups forward a little bit while you wear them, or try to get them to fit as well as you can with the band straight up and down on your head.