Why these are fundamentally different kinds of measurement
Molarity measures how many molecules of a substance are present, expressed as moles per liter (a mole is a fixed, enormous count of molecules — about 6.022×10²³). Mass concentration measures how much the dissolved substance weighs, expressed as grams or milligrams per liter (or ppm, covered in a companion article on this site). A given molarity corresponds to a different mass depending entirely on how much a single molecule of that specific substance weighs.
The conversion formula
Mass concentration (g/L) = molarity (mol/L) × molecular weight (g/mol). This is simply "count of molecules" multiplied by "weight per molecule" to get total weight — molecular weight is the necessary conversion factor between the two, and it's substance-specific, so there's no single universal molarity-to-mass-concentration formula that works for every chemical.
A worked example
A 0.1 mol/L solution of sodium chloride (NaCl, molecular weight ≈58.44 g/mol): mass concentration = 0.1 × 58.44 = 5.844 g/L, which equals 5,844 mg/L, or approximately 5,844 ppm in a dilute aqueous solution (using the mg/L-to-ppm-in-water approximation covered in the ppm article on this site). The identical 0.1 mol/L molarity for a different substance with a different molecular weight would produce a completely different mass concentration — the molarity number alone doesn't tell you the mass without also knowing which substance it is.
Why this trips people up
It's tempting to treat molarity and mass concentration as if they were just two different units for the same underlying quantity, the way Celsius and Fahrenheit are two units for temperature — but they're not measuring the same thing at all. Temperature conversion needs only a formula; molarity-to-mass-concentration conversion needs a formula PLUS a substance-specific number (molecular weight) that has to be looked up or calculated separately for whatever chemical is actually involved.
Where this distinction matters practically
Lab reagent preparation, water-quality reporting, and pharmaceutical dosing all care about this distinction — a solution's concentration might be specified in molarity in one context (chemistry lab work, where reaction stoichiometry cares about molecule counts) and in mass concentration in another (a water-quality report, where regulatory limits are typically stated in mg/L or ppm) — correctly converting between the two contexts requires knowing and applying the specific substance's molecular weight, not just a generic conversion factor.