Surely government is legal by definition?
No, of course.
Whether or not you think it's right or moral
It's not about the moral, it's about constitution and order.
Law has no retroactive effect, so if the new government came into the power through a coup, it will be illegal even if they will illegally adopt a constitution a bit later. That's why any real revolution ends with elections or another legitimate and legal way to form new government.
they make the laws
Government is an executive power. Government usually has no right to make the laws, legislative power does this.