He opposed it to get through the general election (to avoid frightening away centrists who are disgusted by perverts), then had to do a 180 later on; it is an unpopular issue in America, especially in Black America, and it exposed him as a simple stooge of the white liberals.
But Obama is in some ways a fake “African-American” anyway. He himself is reportedly on the down low, and he’s a complete Leftist ideologue.