彼は双方の候補者から票を奪った。

English Translation

He attracted votes away from both candidates.

Can I treat 双方 as a synonym for 両方?

Again, the “System” haunted. Who is the real OP? Is this @ericaw ?

双方 and 両方 are synonyms but 双方 is better fit for formal writings, and I think the English sentence sounds like a journalistic report. Also, 双方 is preferred when it refers to a group of people rather than a single person. Even though there is no running mate, we in Japan usually describe a political election as a team battle because a candidate needs to mobilize many supporters to win the race. For more information about the difference between 双方 and 両方, read this dictionary definition.

Alternatively, you can say:

彼は両陣営から票を奪った。(pron. りょうじんえい)

双方の候補者 means “both candidates” whereas 両陣営 means “both of the election campaign teams”. 陣営 is primary used in the context of warfare. And we regard an election campaign as a sort of democratic war. 陣営 is a frequent term for elections.