Mushrooms are the same deal. Millions of separate organisms somehow spontaneously decide to coordinate and form the structure that will release spores, and some of those organisms become the spores themselves.
How do they communicate? Who is directing? Where are the instructions stored?