Yeah, Iran probably (but who can say for sure) funds terrorism with that whole Death to America thing. And gay marriage was only legal in the US in 2013 or whenever. So not much difference between that and hanging people. Putting it that way, I can see your bafflement.
I think if you believe the US is sanctioning Iran because of their gay rights record then that would be pretty naive. It's all about power and politics. We didn't depose their democratically elected leaders for their benefit, that's for sure.