If a man has two wives, the one loved and the other unloved, and both the loved and the unloved have borne him children, and if the firstborn son belongs to the unloved...
Deuteronomy 21:15 ESV

This commandment is nonsensical if God absolutely forbids polygyny. First, no man could ever really have two wives. Second, if having two wives is adultery, then only the children of the first wife would be legitimate, no matter which wife had a son first.

(This is NOT an endorsement of polygyny or any other kind of polygamy.)