1. Jesus was quoting Jewish (not necessarily Christian) Law and Practice
Jesus was referencing a Jewish custom called levirite marriage. In the Torah, at Deuteronomy 25:5-6, God specifically commands the Israelites to practice this custom, with the explicit purpose that the brother who shall have died should not "have his name blotted out." Put another way, he wanted to provide for the surviving widow and the family legacy.
Indeed, the story of Judah and Tamar even highlighted the crime that Judah committed against Tamar, leaving her destitute and childless when he withheld his third son from Tamar, after both Onan and Er died.
As both custom and Jewish law then, one can clearly establish it was Jewish, but then it raises the question To what extent does the Law of Moses apply?. There are cases to be made that the Torah (also called "the Covenant") does not apply because it was a specific contract between God and the Jews at a specific point in history. (This is called dispensationalism and is very common amongst many Christians.) There is also a counter case, but that is a rabbit trail, because there is a much greater issue with the question.
2. It is bad exegesis to assume every statement is prescriptive.
Even without the context, one would clearly have to misread the text in order to even ask the question.
Jesus was arguing with the Saducees (who deny the resurrection). The Saducees were the ones making an argument even they thought to be absurd here. For example, Pastafarians might well ask a Christian, "How do we know that God isn't a Flying Spaghetti Monster?" Let's pretend for a moment that a biblical writer observed Jesus responding to such a silly question. Would then legitimate the process? Of course not! Just because Jesus listened to someone who was wrong, it doesn't make what the person who was wrong somehow right!
In general, there is a tendency amongst many new or non-believers to turn the Bible into a magic talisman. There is an old joke about someone opening the bible, looking for guidance, and reading:
"Judas went out and hung himself."
Then, the person decides, well, maybe that isn't directly applicable. So he tries again:
"Go and do thou likewise!"
I can take any work, misread obvious intent, ignore the genre, and then find it strange.
Obviously these are silly - no responsible Theologian, be she Christian or Atheist would assume that is responsible. There is a context, and to read without context does violence to the intent of the work.
3. The context is clear
The context is clear - Jesus' opponents bring out an obscure custom in an attempt to make Jesus look foolish. (Oh how times have changed, right?)
Jesus takes the question, listens to it, and corrects the assumption. If Jesus didn't listen, he wouldn't be kind. But how does that legitimize anything?
The Sadducees thought Jesus foolish for believing in a resurrection because woman "obviously" couldn't be married to seven men, even though that is what the Torah (which they did believe) could set up a situation where that would have been the logical result.
Jesus says - If you actually knew what heaven was like, you'd realize the absurdity of your own question.