Is it wrong for a politician to mirror the opinions of their voters? That’s literally what a representative democracy is supposed to be.
Is it wrong for a person to express their heart felt opinion to folks who like and trust them? Isn’t that what all human communication is?
Obama did the right thing, in both 2008 and 2012. If he does 2008 differently, he remains a Senator with no national platform. If he does 2012 differently and doesn’t use his national platform to advocate for gay rights, maybe it takes longer for it to reach 80% support in the general population.
If you’d like to actually understand politics, I’d suggest reading The Dictators Handbook or watching this video for the tldr- https://youtu.be/rStL7niR7gs