When a woman gets married, she leaves her own family (even in modern ceremonies the bride is "given away" by her father).
If her husband dies and they have no children, she no longer has any real relationship to the family she is living with, but neither is it appropriate for her to return to her old family.
If they have a child though, she would be related to them, because she and they are all related to that child.
As described in Deuteronomy 25, to avoid this problem, the eldest brother of the dead husband would "marry" her, producing a child as if it were the original husband's.
If there were no brother, then the next in line (e.g. her father in law) would assume the duty.
A famous and complicated case of this is recorded in Genesis 38.
Jacob's son Judah had five sons, the oldest two being Er and Onan.
Er married Tamar, and then died before fathering any children.
Genesis 38 (NLT)
8 Then Judah said to Er’s brother Onan, “Go and marry Tamar, as our law requires of the brother of a man who has died.
You must produce an heir for your brother.”
Notice that this wasn't a case of Onan deciding to marry a second wife; in fact he didn't even want to marry her:
9 But Onan was not willing to have a child who would not be his own heir.
So whenever he had intercourse with his brother’s wife, he spilled the semen on the ground.
This prevented her from having a child who would belong to his brother.
10 But the LORD considered it evil for Onan to deny a child to his dead brother. So the LORD took Onan’s life, too.
Once the widow had produced a child, she was guaranteed a place in the family because of the genetic connection through that child.
It might be convenient for her to continue living as a second wife, but that wasn't a requirement; she could just live as one of the women in the extended family.
So yes, technically this was a case of polygamy, but a case of obligation, not of free choice.
(For those not familiar with the story:
Judah sends Tamar back to her old family temporarily until the third brother is old enough, but never does send for her, so she poses as a prostitute and tricks Judah into giving her a child.)