This is a misrepresentation of the politics of the time. Bush was to the left of his party on this and out of step with most of the GOP. Obama was to the right of the Democratic base at first and eventually moved more toward their position. Things were not "the exact opposite."
For people who weren't alive to remember the politics of the early 2000s, the debate on immigration was the exact opposite of what it is today.
The Democratic Party viewed open borders as, in the words of Bernie Sanders, a "Koch brothers proposal"-- that Republicans wanted to displace American workers with cheap labor at the behest of their corporate donors.
George W. Bush, on the other hand, was an honest-to-God open borders ideologue. He and Karl Rove had this brilliant theory that importing as many Hispanic immigrants as possible would make our country better and lead to them voting Republican forever.
Then at some point, Democrats realized the only way they could continue to win elections is by changing the demographics of the country-- while a businessman from New York came along to save the GOP from its pathetic leaders of the past.