McCain was arguably a moderate in the Senate
The guy was not a moderate. He was "moderate" (a maverick) on a few issues and so people automatically think of the guy as a complete moderate. It's not true.
Well, he's certainly no Collins or Specter, but something in between. I said "arguably" since McCain doesn't really possess a cohesive personal philosophy about things he doesn't care about.
Nevertheless, the areas where he sided with the Democrats on like immigration, Bush tax cuts, and torture got dropped like a hot potato during the primaries. No one cared about the environment and campaign finance reform anywhere. Thus all he had to work with was his claims to vaguely "work across the aisle"