SS's answer is correct, in that being able to hide your loyalty is important for any secret agent, but there's another important element at play here:
Hydra was SHIELD
People talk a lot about Hydra "infiltrating" SHIELD, or Hydra agents "pretending" to be SHIELD agents. But that's really a false premise: Hydra agents were SHIELD agents. Fully authorized, without any deception or false pretense. Hell, SHIELD was run by a Hydra agent, as we see in Cap2.
Hydra had been a part of SHIELD ever since Zola was brought over after World War 2, which means that it's been almost since the very beginning. The history of SHIELD includes Hydra, SHIELD missions routinely served Hydra's aims, for decades. For all intents and purposes, SHIELD missions were Hydra missions: they were the same organization. Think of it like the American Civil War: just because a Union officer joined the Confederates in 1861 doesn't mean he wasn't a Union officer in 1860. His loyalties were with one side, but before the split the two sides were one. Being loyal to his home state and being loyal to his home country meant the same thing, until they didn't anymore.
Agent Ward seemed loyal to Coulson's team because he was loyal. He was a SHIELD agent. It was only when Hydra split from SHIELD that people had to pick sides, and he went with Hydra. But before the split, Ward was a loyal SHIELD agent, and Coulson was (albeit unknowingly) a very productive and valuable asset of Hydra's.