If it's actually exploded, it's superheated; you need to stir it before putting it in.
If it's just boiled over, you've done it for too long. Undercook it, stir it, wang it back in for 30 seconds.
Once happened to me with soup. Doing a tin of Heinz cream of tomato, like I've done a thousand times. Just before it was due to ping there was an almighty 'kin *bang* like a bomb going off, I tore the door open to find a near-empty bowl and a microwave that was orange with a few spots of white showing through. Always made a point of stirring it first after that.