Gravitational waves and gauge fields in the early Universe