Wisconsin Governor Scott Walker talks during an interview with the Associated Press in New Orleans on May 18. (Gerald Herbert/AP)

Scott Walker was hot and then cold on a path to citizenship for undocumented immigrants. Jeb Bush was yes and then no on invading Iraq. Marco Rubio was in and then out on offsetting increased military spending with other cuts.

The Republican presidential primaries are starting to sound like a Katy Perry song. GOP rivals have adjusted their positions on a host of issues defining the battle for the nomination.

The common thread: They are lurching to the right and struggling to explain themselves, which could bring negative consequences in the general election.

The moves range from minor tweaks to 180-degree turns and are aimed mostly at addressing individual weaknesses early in the contest. Most of the pivots have come on immigration, national security and education, reflecting an urgent desire to fall in line with a party that has become more conservative on several fronts since the last presidential election.

“The conservative agenda is what is winning the field,” L. Brent Bozell III, a leading conservative activist, said. “And people who have either not taken a conservative position or took one softly are having to commit if they want to win the primary.”

Republican presidential candidate Sen. Marco Rubio, R-Fla., speaks at the Georgia Republican Convention, on May 15 in Athens, Ga. (David Goldman/AP)

Hillary Rodham Clinton, the clear front-runner for the Democratic nomination, is also catering to her party’s base. Republicans claim she has flip-flopped on support for a Pacific Rim free-trade pact that is strongly opposed by labor unions and progressive activists.

Democrats say they are happy to see Republicans race to the right, since they believe it will put the eventual GOP nominee out of step with the general electorate. Some Republicans are nervous about that possibility.

“You have to be careful when you are doing this — that you don’t so embrace your base that it becomes impossible to move and have some flexibility or nuances in your position moving forward,” Rep. Tom Cole (R-Okla.) said.

All of the candidates are also mindful of how damaging it can be to be tagged a hypocrite. Recent White House nominees John F. Kerry (D) and Mitt Romney (R) struggled against accusations they put a finger in the wind to decide where they stood.

“There are levels of flip-flops. There are issues where people change because the world ­changes, circumstances change,” said Steve Elmendorf, a longtime Democratic strategist. “As long as you explain what you are doing and why, that’s fine.”

Franklin D. Roosevelt campaigned for reelection in 1940 on a platform of not getting entangled in foreign wars. But after the Japanese attack on Pearl Harbor, Roosevelt changed his mind, and few remember his earlier reluctance.

New Jersey Gov. Chris Christie, a likely Republican 2016 presidential candidate, recites the Pledge of Allegiance at a town hall meeting in Hudson, N.H., on May 18. (Charles Krupa/AP)

This cycle’s aspirants are trying to present their moves as authentic personal shifts, reflections of a changing world or not flip-flops at all. But it’s been difficult.

Walker, the Wisconsin governor who is expected to run for president, has struggled for months to square his position on immigration reform. Two years ago, he was for granting citizenship for undocumented immigrants. This year, he was against it. But then came reports he was privately for it, so he declared that he really was against it.

This week, Walker said he hasn’t really flipped at all because he never voted on the issue.

“Well, actually, there’s not a flip out there,” he insisted in a Tuesday interview with Fox News. “A flip would be someone who voted on something and did something different. These are not votes.”

Immigration has been especially tricky for Republicans. After a dismal showing with Hispanic voters in the 2012 election, many GOP leaders called for the party to embrace reform. But conservatives sank a sweeping bill in Congress, and President Obama enraged Republicans by acting to change regulations unilaterally.

Meanwhile, key elements of immigration reform have lost popularity among the party’s base. Polling from The Washington Post and ABC News found opposition to a path to legal status rose among conservative Republicans from 59 percent in fall 2013 to 73 percent a year later.

As public sentiment shifted, so did the stances of politicians. Rubio, a White House hopeful who was part of a bipartisan group leading the reform effort in Congress, now backs a piecemeal approach that begins with border security and enforcing current laws. New Jersey Gov. Chris Christie (R), a possible presidential candidate, said this week that he no longer backs a path to citizenship.

Democrats say these kinds of moves to appeal to the conservative base will bring consequences once the primary is over, since moderate voters hold sharply different views. “Some of them are flip-flopping to get to the wrong positions for the general election,” Elmendorf said.

Republicans also have adjusted their views on national security in a hawkish direction as concerns about the threat of the Islamic State terrorist group have risen.

Bush, the former Florida governor who is preparing to enter the race, got badly tangled last week on Iraq — an especially sensitive issue for him, since his brother authorized the 2003 invasion of the country.

Bush first said that he would have invaded even knowing that Iraq did not have weapons of mass destruction. Then Bush said in a radio interview that he didn’t know what he would have done. Finally, he said at a campaign-style stop that he would not have authorized the war, knowing what is known now.

Over the weekend, Bush brushed off suggestions that this fumble was a sign of weakness, saying, “Look, we are all going to make mistakes.”

Iraq also has tripped up Rubio, who said in late March that he did not think the war was a mistake but said last week that, knowing what we do now, he wouldn’t have invaded. He strained to reconcile the two positions in an awkward “Fox News Sunday” interview.

For Rubio, who launched his campaign last month emphasizing a hawkish national security platform, the rhetorical muddle highlighted a broader shift to the right. He favored offsets to cover higher defense spending in 2013, but this year he introduced a budget amendment that did not include them.

Even Sen. Rand Paul (R-Ky.), whose political rise is tied to his libertarian leanings on national security, has sounded more forceful notes about fighting the Islamic State and increasing defense spending.

Flip-flop charges on national security can be hard to overcome. Republicans tagged Kerry as a flip-flopper on Iraq and other issues to devastating effect in 2004. One particularly potent attack ad showed Kerry windsurfing as a narrator mentioned his vote for the Iraq war and his vote against George W. Bush’s $87 billion request for military and reconstruction funds in Iraq and Afghanistan.

“John Kerry — whichever way the wind blows,” the narrator said.

And then there’s Common Core, the education standards most states implemented years ago — only to see an angry backlash from conservatives. Louisiana Gov. Bobby Jindal (R), who announced the formation of a presidential exploratory committee this week, was once a champion of the standards but is now one of its most vocal critics.

Other areas have proved tricky for Republicans to reconcile their past statements with their present platforms. Walker, for example, has long opposed abortions. But facing a pro-abortion rights Democratic female challenger last year, his campaign released an ad with a script that borrowed language from the abortion rights movement as Walker defended a new law requiring women to undergo an ultrasound before having an abortion.

Walker brought up the ad during a Tuesday afternoon meeting with a few dozen social conservative activists in Washington, according to several attendees. He wanted them to understand the context: The ad was a defense of legislation that he signed into law, not a softening of his staunch opposition to abortion. He asked those at the meeting not to use the ad out of context against him.

“I have no doubt that he’s very pro-life,” said Marjorie Dannenfelser, president of the Susan B. Anthony List, who was at the meeting. “You heard his heart in there, and I believe it. But the proof is in the action.”

Some Republicans caution not to read too much into what the early position-adjusting and fine-tuning will ultimately mean in the long primary process. Stuart Stevens, a top adviser to Romney in 2012, is one of them.

Said Stevens, “It’s like watching people warm up for the Super Bowl and then saying: ‘What do you think the consequences will be in the third quarter?’ ”

Scott Clement and Robert Costa contributed to this report.