In many states it is illegal to marry your first cousin, but in some it is legal. Suppose you married your cousin in a state where it is legal, say New York, and moved to a state where it is illegal, say Utah? Would your marriage be legal or illegal? What if you had children?
Thankfully, states generally recognize marriages of first cousins who are married in a state where such marriages are legal; otherwise, there would be chaos in our highly mobile country.
Yet if a legally married same-sex couple with children moved from New York to Utah, their marriage is dissolved. Think of the chaos for that family, the children learning their parents are no longer married.