It's simple: the real subject of the first sentence is Glas, and Marmelade modifies the nouns used by the subject in a sense. So the subject is the main topic, and the complexity of translation is 10 bottles of jam.
In the second sentence, its glas becomes a noun that only modifies quantity, and the subject shifts to bier, which means: 5 glasses of beer.
In fact, these two things mean the same thing.
In fact, there are more second sayings in daily life.