How is a wedding cake offensive?
That is irrelevant.

No one can compel anyone to make a political cake. 

The baker has already made many cakes for gay weddings, he just did not know about it. If he did, he would have refused. 
So he is only offended when he knows it is a gay wedding cake. It is childish.

The baker is choosing to be offended. Religion is not an excuse to discriminate.