My best guess is, that your mavic switch to atti mode due to lost of gps signal and poor lighting (if it is bright enought, it will switch to P-Opti mode instead)
It would be better to upload your flight log here to be assessed by the more experienced member for better understanding of what happen