Touch it. Go on, we dare you.
This serves a dual purpose. First, the yellow goo is toxic, so there's a good chance it will simply kill the aggressor outright. And if that doesn't work, it's also extremely sticky -- it effectively glues the exploding ant's (now) corpse to its enemy. So even if whatever attacks an exploding ant is sturdy enough to survive being massively poisoned, it'll still have to live out the remainder of its short life in a horrific, involuntary remake of Weekend At Bernie's.
Or if the exploding ant is really sadistic, Weekend At Bernie's 2.
It sounds insane, but it's not uncommon for highly social insects such as ants to go kamikaze to protect their nest. Thing is, exploding ants will do it at the slightest provocation -- a gentle poke with forceps in a lab is enough to make them initiate ass-bursting protocol. They'll even do it hundreds of meters away from their nest, if a larger ant so much as takes a step onto their foraging grounds. That's sort of like blowing up your neighbor at the Food Lion on the off chance that they might snatch the last tub of macaroni salad.