It depends on the situation.
In a region where one party is clearly going to win, the Primary is unofficially the general (i.e. In my home state, it is best to Register Democrat because they (usually) always win and the primary is closed.).
Other people will vote for Party A to vote in their primary for the weaker candidate as they want to give Party B's candidate the better shot.
Your situation is closely mirrored to either the above or the below:
You do not care which Party gets the job, so long as the incumbent Candidate is not on the ticket. Here it is to your benefit to register for the Incumbent's Party and vote against him twice.
There are also independents who like both candidates equally (or hate them equally) and want to see the best of both parties before making a decision, which means they will not participate in either primary. This is probably the weakest as they cannot influence the more dominant party, but some voters are principled in their non-committed party lines voting.
Though rare, there are states with open primaries where all voting members can vote for any party they choose without registration (a member registered to Party A can vote on Party B's primary instead... as can an independent) and some where you can vote on both parties (probably the fairest as it is picking your two favorites).
In the United States system, your political party really only matters to the public once you decide to run for an office. While it is never illegal to change parties, America tends to abhor a flip-flop more than an open minded person who realized he no longer agrees with the party line. (Most losing presidential candidates in my life time were seen as the one who's exact beliefs were harder to pin down.). So you can bounce between parties as much as you want in the United States until you decide to run for office... than you better be prepared to part with the party only on pain of death or (worse of an elected official) future political career.