Translation:What is the legal age for marriage?
That's not a very natural way to ask that question in English. We would ask, "How old does a person need to be to get married?" Something along those lines.
What is the legal age for doing something takes a verb, not a noun. What's the legal age for voting, for drinking, or smoking, for getting married?
Yeah, I would call that a gray area. It's a matter of proposition choice. Obviously, either "of" or "for" is grammatically correct and makes perfect sense.
However, technically, the sentence is written with "per" so "for" would be the more correct translation. Your grader is a computer and they are notoriously unforgiving.
I think that would mean that you are asking for the definition of the legal age of marriage. "Cosa" is used among other things to ask for a definition, while "qual" asks for a choice between alternatives, such as which number is the legal age of marriage. Hth, Thomas