JT on line is right that Mazda have all the diagnostic tools and processes to help here. I am just wondering though if , assuming it’s the original , the battery might be playing up here?
I had one or two odd starting behaviours plus unusual warning lights. Took the decision to replace the 6 year old battery -everything fine since.
Just a suggestion.