This. I don’t know why people found Obama’s position on gay marriage so difficult to understand. It was simple. In 2008, he had to win a Democratic primary. This meant echoing the stances that would be popular with Democratic primary voters. In Obama’s case, he needed all of the black vote as well. Only 60% of Democrats in 2008 supported marriage equality, compared to 80% in 2020 (
https://news.gallup.com/poll/350486/record-high-support-same...). Black voters are more likely to be religious, more likely to regularly attend church and therefore less likely to support marriage equality (
https://news.gallup.com/opinion/polling-matters/182978/relig...). Pleasing black voters meant taking a “safe” stance on gay rights, one shared by all mainstream national politicians at the time.
In 2012 it was different. There was no primary. Obama could afford to be less of a follower and more of a leader. Black voters might not be enthusiastic about gay rights, but there was no doubt they’d show up to vote for their guy. So Obama calculated he could get the black vote and the gay vote by “evolving” his public stance.
This is of course separate from his own personal stance, which likely hasn’t evolved in a long time. What people find difficult to understand is that public figures have public and private personas.