And there’s another important term; “to vote in favour of the law so harmful to the common good is gravely immoral”.
In addressing the role of the state, the Catholic moral tradition had never held that it is the business of the state to prohibit or penalise a particular behaviour merely because it is considered to be immoral. Which is why the Catholic tradition is fine with, say, adultery or prostitution not being criminalised.
It’s not, in the Catholic view, the business of the state to enforce general morality; it’s the business of the state to uphold the common good. There’s a large overlap there, obviously; acts of violence, fraud, etc are both immoral and contrary to the common good. Nevertheless the two concepts are distinct.
So, in relation to lawmakers, the document doesn’t say that they must oppose gay marriage because gay relationships are immoral and endorsing or recognising them supports immorality; the claim is that endorsing or recognising them as marriage is contrary to the common good; it injures the community in some way.
But discerning the common good is clearly a matter of judgment; of the application of principles and values to real facts and situations. For example, is the common good served by prohibiting alcohol, or by licensing it, or by allowing a free-for-all? Is the common good served by having a low driving age and a high drinking age, or the other way around? Is the common good served by prohibiting gambling, or by regulating it? By free education, or student loans? These are weighty moral issues, but there can legitimately be different opinions on them, and you can arrive at different answers in different circumstances. Laws concerning alcohol, say, that might work quite well in the US might work very badly elsewhere, or vice versa.
Answering questions like these is the vocation of the legislator, not the bishop. Bishops may have opinions on them - strong opinions, possibly even well-argued and well-reasoned opinions - but, still, questions like this are not within the range of matters of “faith or morals” on which the church claims to offer definitive teaching.