I don't live in either state, but...
-Hurricane Sandy hit the more Republican areas of NJ.
-Linda McMahon spent a ton of money and perhaps her GOTV helped Romney.
-Obama was weak among Wall Street types in the Gold Coast area.
-Obama was weak among the white, lower middle-class New England types because of racism.
-Romney is from New England and was a finance guy so he was stronger with both groups.
-NJ has slightly more black folks and their turnout dropped less from 2008 than other groups.
-NJ has more Asians who swung towards Obama in 2012.
The two in bold I'd dispute. McMahon actually made some effort to distance herself from the national GOP (there were ads of people saying they were voting for Obama and McMahon), and there are way more blue-collar whites in New Jersey than in Connecticut. In fact, it seems that working-class white ethnic (Italian, Polish, etc) communities in New Jersey had some swing to Obama thanks to Sandy.
But the primary reasons, as stated, are that New Jersey is a more ethnically diverse state and it was hit hard by Sandy.
McMahon may have made ads that said that but, she did spend $12 million dollars. No other Republican campaign in NJ or CT spent serious money on statewide organizing and GOTV. That could have had some effect in boosting Romney.
Also, I think lower class whites in New England are especially racist.
That's not true. Lower class whites in Connecticut are especially likely to support Obama. Think lower class Italians, Hispanics, Portuguese, etc in cities like Stamford, New Haven, and Bridgeport. The reason Obama underperformed in Connecticut was for the opposite reason; Romney appealed to the wealthy, white Wall Street crowd in Fairfield County more than other Republicans. That, I believe, is the main answer to the OP's question.