An astrophysical dynamo is a mechanism by which a body transforms thermal and kinetic energy into electrical energy and through it, generates and maintains magnetic fields. It is analogous to an artificial mechanical dynamo, a type of electric generator, but rather than a mechanical commutator, electricity is carried by fluids that are moving and conduct electricity. The body must be spinning and carry a conducting fluid. The mechanism works according to the rules of magnetohydrodynamics.
There exists a "chicken-and-egg" issue: electrical current is generated by a conductor moving through a magnetic field, which, in turn, is formed by the electrical current. Starting the process only requires that a weak magnetic field be present, e.g., a weak magnetic field surrounding it, or very slightly magnetized objects in the vicinity: if conditions are right for a dynamo, any present magnetic field is effectively amplified to what the dynamo can support.
The Earth's magnetic field is maintained by such a dynamo (the geodynamo), with molten iron in the core being the conducting fluid. The Sun also has such a dynamo (solar dynamo), its gaseous interior being a conductor: this is the solar magnetic dynamo model thought to explain the visible solar cycle. Other stars, planets, as well as galaxies are thought to maintain magnetic fields through the dynamo mechanism. I assume the Sun's magnetic field could "seed" the Earth's dynamo, but I'm not sure how magnetism was first triggered in the solar dynamo: perhaps by convection including ions.
The presence of a magnetic field around a rocky planet or moon implies the presence of a dynamo, implying a molten core, convective mantle and plate tectonics. Such convection, in turn, is a sign of world cooling, e.g., from residual heat or from an active energy source such as radioactivity or tidal forces. Weak and/or scattered magnetism that suggests a dynamo in the past but not the present can reveal information about the thermal history of the body, a case in point being the Moon. A planet's magnetic field characteristics depend upon characteristics of its core's history, e.g., if it was all liquid, and its heat distribution so as to produce convection, which, in turn, is factors to be considered in the planet's formation process.
While there is evidence that dynamos produce the magnetic fields of astronomical bodies, realistic models of convincing detail remain a challenge and it has been established that some asymmetry, e.g., from turbulence is necessary, i.e., that an axis-symmetric magnetic field wouldn't produce one. One attempt to model the complexity is to apply something like Reynolds decomposition to MHD, which has been called mean-field MHD, and the corresponding theory of dynamos, the mean-field dynamo theory.
A disk such as a protoplanetary disk or accretion disk may form a dynamo if it is ionized and material flows in a curving motion, e.g., turbulence. For example, a gravitational instability dynamo or GI dynamo.