A study of galaxy formation across cosmic time from cosmological hydrodynamical simulations