The pattern for the first sentence is:
[number] + [unit] + [name for what is measured]
3 Meter Seide - 3 meters of silk
40 Liter Benzin - 40 liters of gasoline
7 Tonnen Schotter - 7 tons of crushed stone
6 Dutzend Eier - 6 dozen eggs
4 Millionen Euro - 4 million euros
2 Stück Zucker - 2 pieces of sugar
In the first 3 examples you have "real" physical units. The units in the last 3 examples are words for numbers, but they work the same way.
The examples Tonnen and Millionen show, that the unit normally is used in its plural form when the number is different from 1. The plurals of Meter, Liter and Dutzend are equal to the singular forms, so they don't help here.
But Stück is different. It behaves different when it is used as a "normal" noun or as a unit. When it is used as a unit, it's plural form is equal to its singular form. In other cases you have to add an -e:
- used as unit:
- Ich möchte bitte 2 Stück Zucker in meinen Kaffee.
- Wieviel Zucker möchtest du in deinen Kaffee? - Ich hätte bitte gerne 2 Stück.
- Wieviele Bücher sind in diesem Regal? - Ich schätze mal ca. 250 Stück.
- not a unit:
- Der Künstler hat innerhalb eines Monats drei neue Stücke komponiert.
The examples 2 and 3 also show, that the name for the things that are measured also can be omitted. It is enough tho know from the context what it is.
In example 4 the word "Stück" is not used as a unit. Here it is the name for the things that are counted. (Here: Stück = play or composition)
The second example can be interpreted in two ways:
- Sechs Glas Cognac
- Sechs Cognacs
In 1 we have the same pattern as above. And "zwei Cognac" is just an ellipsis of this form. (Ellipsis = when something is omitted, that everybody would guess right.) But then Cognac behaves like water, milk, honey, air, ...: It is the name of an uncountable material, which means it can not be used in plural.
Two waters, 5 honeys and 7 airs really mean two kinds of water, 5 kinds of honey and seven kinds of air. And this is exactly the same in German. And so, in English and in German you can have two bottles of water (zwei Flaschen Wasser) but not two bottles of waters (zwei Flaschen Wässer). And this is also true for cognac.
In version 2, "a cognac" is not meant as the name of a liquid, but as a name of a portion of it, i.e. a glass of cognac. And when it is used this way, you can count it, and so you also have to use its plural form.
So, both versions are correct.