You've asked a great question, and there has been quite a bit of debate on this/ I'll try to pose some ideas in segments, based on my time and what others may add...
Pirkei Avot 1:10 cites Avtalyon who says:
שנא את הרבנות
There have been several interpretations of this phrase but one of them, cited by Rabbeinu Bechaye, in the link that I have shown interprets this that one should shy away from a leadership position unless someone specifically imposes it upon them. Thus, at least in U.S., many governmental positions are by election, so no one is ever forced to be a candidate. There may be a different situation if the president "coaxes" you into a cabinet position, but, even that can be refused. (I state MAY be different, because I'm uncertain of the parameters of what "imposed upon" includes within Rav Bechaye's definition.)
Rav Bechaye cites contrasts that Moses repeatedly refused being a leader until G-d forced it upon him. Similar idea with Shaul Hamelech (King Saul) who hid among the baggage because he didn't want to be king.
In contrast, he says that those who voluntary accept leadership end up dying before their time, as we see that Joseph was the first to die among his brothers.
There is a separate problem of accepting government positions in that, as you mentioned, it frequently does conflict with one's Jewish moral principals, as you are now a servant of the public. Pirkei Avot does mention this aspect as well. I will edit that in, when I locate it.
When Senator Joseph Lieberman ran as vice president during Al Gore's campaign, we saw some of these very aspects occurring. See this article for the full story. His rabbi stated that one is allowed to violate the Shabbat for the sake of the public "good". I'm not trying to debate the rabbi's validity on that statement. However, it does preclude the notion that one, perhaps, shouldn't intentionally enter a situation where he has to have this type of debate in the first place.
One other general rule, is that one should avoid situations where he will most likely be forced to violate halachot, assuming that he has a choice. One of my friends was deciding if he should become a surgeon or an accountant (I know - it's a strange choice!) His rav told him that unless he has a tremendous urge or desire to become a surgeon or there is a specific communal need for his expertise, he should become an accountant, because a surgeon is likely to be called on emergency on Shabbat and he may have to drive to the hospital. Of course, he is allowed to do that, but, the rav was pointing out that one shouldn't voluntary enter such a situation if he can avoid it.
Likewise, one should probably avoid entering a situation where he may have to compromise his Shabbat observance, or other halachic conflicts. Although, as I mentioned in my comments, I can't see any situation other than U.S. president where someone would need to violate Shabbat for any reason other than a natural disaster decision or impending war, etc.
There are other conflicts, probably, which I will try to add later.