Well, sure, and most laws are written for that purpose, to discourage certain behaviour. Obviously, laws can't be written to discourage being, i.e., a law establishing it illegal to be a woman.
You bring up an interesting point. Almost all the laws in respect to homosexual activity (sodomy laws for example) are directed to male homosexuals. Women homosexuals generally are seldom arrrested or charged with any misconduct except in the cases of children.
It is for the above reason that Freud concluded that men wrote the laws to control their own unconscious inclination to act out their hidden homosexual inclinations. This theory is unimportant perhaps but id does explain some facets of the law, men and homosexuality.