Jacob Gagai scored two second-half tries as Huddersfield made it back-to-back Super League wins by beating York 34-14 at the Accu Stadium.