Galactic magnetic fields and hierarchical galaxy formation