Barred galaxies in the EAGLE cosmological hydrodynamical simulation