The units aren't the same. The shorthand for the units is the same.
A dollar of market cap is very different from a dollar of GDP, like a cubic meter of lead is different from a cubic meter of air.
What we're talking about is the value (or weight); the denomination (or volume) is irrelevant.
The value of a dollar GDP is considerably more tangible than a dollar market cap.