I'm designing an alien tree species that produces small purple fruits at the edge of its braches. Now a few seconds after one of these fruits falls from the tree it makes a small explosion so that its seeds can grow into new trees in a different location. My quiestion is, how could such a mechanism of explosion work for a fruit, and how could something like that evolve in the first place
You're lucky, this is a case of "nature already did it". A combination of melting resin, high internal pressure and physical tension works for various existing plants such as the squirting cucumber, touch-me-nots, persian silk trees, yellow woodsorrel and violets.
You can watch slow-mo videos of them on youtube, decide on which method you prefer and then just copy it.
You have two really good, informative examples (one as an answer, one in the comments) of real-world scenarios. So here is a really wild, out-there but plausible answer.
The fruit has formed a really good symbiotic relationship with a particular strain of bacteria. The plant provides these bacteria (located in the fruit pod) with nutrients, and the bacteria produces methane gas as a byproduct.
The fruit pod outer membrane is made of a tough, elastic protein (similar to intestines) that constrains this methane under pressure.
When the seed pod (fruit) falls, the nutrients to the bacteria are cut off, and this signals the bacteria to start consuming the enveloping membrane of the pod. This forms a hole, and the external membrane collapses like a balloon. The guts of the pod are expelled.
The exposure of the bacteria to air causes them to create high voltage sparks, that ignite the methane, creating an even larger explosion, that propels the seeds far and wide, along with the bacteria. Thus, the seeds and the symbiotic bacteria are equally dispersed.
Very recently, it has been discovered that, indeed, certain human gut bacteria do produce electricity in sufficient quantities to be usable for this purpose.
The electricity could be stored in biological capacitors until it becomes sufficient enough to cause ignition.
The physics textbook, along with the Chemistry and Biology textbooks, are recently getting very thick indeed. Knowing this makes sci-fi writing all that much easier, without calling on magic.
The best Earthly example is the 'dynamite tree' (Hura Crepitans). The mechanism depends on 'dehiscence' which is seam[s] in the seed pod that remain weak while the rest hardens. If the hardening takes place unevenly then stresses can build, like a leaf spring. When the dehiscence zone begins to decay, it will let the springs go, and the seeds can be propelled.
It probably evolved in stages: A decaying pod to release the seeds; a hardening pod to protect the seeds; spring power selected as farther dispersal out-competes.
A member of the cucurbit family (same as cucumbers) does accumulate enough pressure to detach and blow-up at the slightest touch. Its liquid content is spitted along with the seeds. The plants belong to the genus ecballium. https://en.m.wikipedia.org/wiki/Ecballium
If you want to add a chemical explosion, the fruit may contain two sacks of chemicals at its center. The seeds will develop at the periphery. When the separating membrane ruptures, the two chemicals come in contact and react violently. The fruit explodes and scatters the seeds.
Water pressure and weak skin: the plant "pumps" water into the fruit as it ripens, while thinning the skin. When the ripe berries (a type of fruit which just happens to be small) falls to the hard ground, the skin bursts, and the seeds -- which are on the outside of the fruit, by definition of being a berry -- get pushed away.