Magnetic fields play an important role in astrophysical accretion discs and in the interstellar and intergalactic medium. They drive jets, suppress fragmentation in star-forming clouds and can have a significant impact on the accretion rate of stars. However, the exact amplification mechanisms of cosmic magnetic fields remain relatively poorly understood. Here, I start by reviewing recent advances in the numerical and theoretical modelling of the turbulent dynamo, which may explain the origin of galactic and intergalactic magnetic fields. While dynamo action was previously investigated in great detail for incompressible plasmas, I here place particular emphasis on highly compressible astrophysical plasmas, which are characterised by strong density fluctuations and shocks, such as the interstellar medium. I find that dynamo action works not only in subsonic plasmas, but also in highly supersonic, compressible plasmas, as well as for low and high magnetic Prandtl numbers. I further present new numerical simulations from which I determine the growth of the turbulent (un-ordered) magnetic field component (B turb ) in the presence of weak and strong guide fields (B 0 ). I vary B 0 over five orders of magnitude and find that the dependence of B turb on B 0 is relatively weak, and can be explained with a simple theoretical model in which the turbulence provides the energy to amplify B turb . Finally, I discuss some important implications of magnetic fields for the structure of accretion discs, the launching of jets and the star-formation rate of interstellar clouds.