Ursus is correct about that - please read about it. Like yourself, Obama was against gay marriage and was open about his opposition to gay marriage in his 2008 campaign when he was originally elected. Biden was very instrumental in getting Obama to change his position on gay marriage. Hopefully like Obama you've similarly evolved.
By the time of his Senate run in 2004, he said he supported civil unions and domestic partnerships for same-sex partners but opposed same-sex marriages.[242] In 2008, he reaffirmed this position by stating "I believe marriage is between a man and a woman. I am not in favor of gay marriage."[243] On May 9, 2012, shortly after the official launch of his campaign for re-election as president, Obama said his views had evolved, and he publicly affirmed his personal support for the legalization of same-sex marriage, becoming the first sitting U.S. president to do so.[244][245]
en.wikipedia.org
You're incorrect about Trump too... as a former Democrat Trump is all over the map and doesn't really seem to have any policy positions beyond what is good for him in the moment, but there is definitely evidence he's fine with gay marriage...
in November 2016, a few days after he was elected president, Trump suggested that he did not, after all, plan to nominate justices who would overturn the Obergefell ruling. He told Lesley Stahl on 60 Minutes his personal view on same-sex marriage was "irrelevant," that he was "fine with" same-sex marriage, and that the Obergefell decision had "settled" the matter[158][164] (though some expressed skepticism that he had really changed his position).[165]
In 2019, his counselor and spokeswoman Kellyanne Conway claimed that he approves of same-sex marriage.[166]
en.wikipedia.org