I run into this occasionally. As long as I notice it, it's not a huge deal, since it's fixable. When it slips through, it messes up the end result though.
Not sure what triggers it, but occasionally a layer mask get's "random".
I think the video below clearly shows it: in the layers panel, you see the layer mask weirdness happening, and in the end of the video, you can see that a simple brush stroke in the mask fixes it (suggesting that the correct mask info is there, somewhere under the hood).
MacStudio, OSX 12.6.1, PS 24.1.1
(But I've run into this before on my 2010 MacPro as well)
Link to video:
PS displaying layer mask weirdness