The glass in microwave doors are made to not shatter and to be safe.
However sometimes during the manufacturing process of the microwave door glass there can be defects and impurities in the microwave door glass.
Then after some heat and cool cycles of the microwave the glass decides to shatter as a result of those impurities and defects in the glass that you cannot see.
It's rare that microwave glass will shatter but sometimes it happens due to those impurities and the glass in the microwave door is designed to break in small pieces for safety.
You might be able to replace the glass on the microwave depending on the model and the value of the microwave or just buy a new microwave.