Even if you accept the premise that the morally optimal course of action is X, it does not logically follow that the government should mandate X.
More generally, reaching the moral conclusion that agent A should do X (or even is obligated to do X), doesn’t obviously entail that agents B, C, D should compel A to do X, nor punish A for failing to do X — nor even that B, C, D are permitted to do so.
More generally, reaching the moral conclusion that agent A should do X (or even is obligated to do X), doesn’t obviously entail that agents B, C, D should compel A to do X, nor punish A for failing to do X — nor even that B, C, D are permitted to do so.