I've experienced 4 cases of this. Two of them on the same track day recently.
The first I think was when the brakes overheated. The car flipped on the hazards and took itself out of track mode.
The second I don't recall the details.
The third and fourth involved a red flag lap, me turning on the hazards, and it taking itself out of track mode.
My theory has been twofold:
1. certain situations causes the car to "be upset" and turn the hazards on
2. whenever the hazards are used the car takes itself out of track mode
In all cases there was an audible warning and likely something on the screen, but it dismissed too quickly (at 80+ mph) to read and there's log for me to look at.
2018 M3P, delivered in June 2018 IIRC