I own both the AirPods Max and the Sony WH-1000XM4, and to me the XM4s have better ANC.
The reason is that with my APM, I get a small gap beneath my ears when I turn my head, which affects the ANC a lot. Getting a good seal is alpha and omega to good noise cancellation, and as long as I sit perfectly still, or don't turn my head, the ANC of the APM is great! But, as soon as I turn my head, there's this gap that lets the noise in. I've tried just about "every trick in the book", without finding a good solution. But, I wish I did, as I prefer the sound (and the spatial audio) from the APM for longer listening sessions.
And, as others have said, the transparency mode of the APM is way better than the XM4s.
But, I find myself reaching for my Sonys most often when I want some over-ear headphones when out and about.
They fit perfectly, which again makes the ANC better (to me), and they have a more "fun" sound than the more neutral APM, when I want some extra bass and punch to the music (which I often prefer when I go for a walk).