Two issues: levirate laws and popular Jewish writings.
This issue is really addressing the Levirate laws from Deuteronomy 25. The idea of the Levirate laws is that the memory of the 1st husband lives beyond the grave which is very similar to the idea of resurrection.
The second issue has to do with popular Jewish writings:
So much of the thoughts on the Resurrection are being sorted out in the period between the two testaments - the intertestamental period (around 450 years).
Two very popular writings that address the idea of resurrection are Tobit and 2 Maccabees. Both of these writings are found in the Apocrypha which can be found in the Catholic bible. Both of these writing address the issue of resurrection in the face of injustice.
There was a very popular story within Tobit (Tobit 3:7-17) about a woman named Sarah who had seven husbands. They all died. In order to keep their names alive beyond the grave, Tobias is commanded to marry her. Tobias is the only son of Tobit. Tobit, therefore, is risking losing his only son to save someone else. Tobias becomes a "kinsman-redeemer."
Peter G. Bolt sees Tobit as the background for this question. He writes:
"the book of Tobit most probably provided the Sadducees with their story. Both they and Tobit talk of the death of 7 husbands and Levirate marriage in the context of an interest in the resurrection.
He goes on to say:
"the hope of the resurrection of Israel that is under discussion. The Sadducees, as the politically advantaged, perhaps had no need of such hopes, especially if they were drawn from non-Mosaic teaching and reinforced by such contradictory case studies as that of Tobit. For the Pharisees, however, such hopes were a crucial part of their prophetic heritage and any rejection of them would deserve the kind of sharp rebuke that Jesus serves his opponents."
The second story is more directly related to resurrection. It is from 2 Maccabees and involves the persecution of Antiochus IV Epiphanies, the Seleucid Greek king. The holiday of Hanukkah stems from this time period.
A woman has seven sons. Each is put to death for their righteousness. The fourth son says this (2 Macc. 7:14):
I am glad to die at your hands because we have the assurance that God will raise us from death. But there will be no resurrection to life for you, Antiochus!
The reason they use a story with "seven brothers" is because it would have been a familiar story to the audience. They are drawing on their cultural and literary context.
Hope this helps.
Bolt, Peter G. What Were the Sadducees Reading? An Enquiry Into the Literary Background of Mark 12:18-23, Tyndale Bulletin 45.2 (1994)