It fires explosive chemicals out of its tail onto its enemies.
Does it make sense that the beetle learned how to do this over time?
Nope! Explosions are deadly. So, these beetles would have killed themselves before ever figuring out the right chemicals, the right mixture of them, and the right process to create a safe but effective explosion.
This tiny creature is a masterpiece of engineering, and its explosive abilities are quite complex.