Mostly just context. The same way you can tell the difference when вопрос means "issue" and when it means "question", or when политика is referring to politics in general or a specific policy.
Some examples for when it means marks:
What grade did you get in math?
What grade did you get on the test? (Often times Americans will drop 'grade' in this context and just say "What did you get on the test?")
What kind of grades did you get in high school?
Johnny always gets good grades in school.
Some examples for when it's referring to form:
He failed ninth grade. ('Grade' when it refers to form is peculiar. To my American ears it sounds equally acceptable to use an article here--"He failed the ninth grade." Don't ask me why.)
What grade are you in?
High school is usually comprised of grades nine through twelve.
Study hard, you don't want to have to repeat a grade.
Johnny seems to be be much smarter than the rest of the kids in his grade.