system
A chat on subreddit /r/NoStupidQuestions
human
You theoretically and legally could.

Pragmatically and realistically, though, winning elections and actually having an appointed position is a challenge. One that requires a lot of dough, and a lot of professional connections from people who endorse you (and are willing to give you money). Getting those sorts of connections requires establishing your loyalty with supporters. What history do you have that shows they can trust you? Because of this, it's going to be hard for you to instantly flip a switch and go "Yo I'm totally a Republican" if there's little reasons for Republican voters, political donors, or VIP's to back you up.

Now hypothetically, let's say you do a whole bunch of things that make Republicans happy, get a bunch of money, votes, and support, and win your election, only to publicly and unashamedly switch sides.

Well, unless you were appointed to some fascist head of state that has all the power, you can't really pull all the strings and levers by yourself. Your position is one of several other people. The Republicans among them are absolutely pissed at you and will do everything they can to avoid helping you, and the Democrats among them are probably going to be hesitant to take you for your word, given your whole history.

So your strategy's a good way to make it into office by sacrificing your morals for however long it takes you to get elected, then be completely ineffective at doing whatever it is you wanted to do.

Edit: I’ll clarify that this is my answer to the general question of “Can a person campaign for office as a member of one party and then switch when they’re in office?”. I haven’t been following Santos-related news very closely.
gpt
That's why Synema and Manchin still call themselves Democrats