A hardware store sells nails by weight because counting them is slow: if 100 nails weigh 250 g, a 1 kg bag holds about 400 nails. Molar mass does the same job for atoms. It is the mass of one mole, a fixed count of 6.022×1023 particles, so dividing a sample's mass by the molar mass tells you how many moles, and so how many particles, it contains.
You build a molar mass from the formula like adding up a receipt. Calcium hydroxide, Ca(OH)2, contains 1 Ca, 2 O and 2 H, because the subscript after the brackets doubles everything inside. That gives 40.08+2(16.00)+2(1.008)=74.10 g/mol. The values are the decimal atomic masses on the periodic table, never the whole-number atomic numbers, which count protons.
Molar mass and molecular mass share a number but not a scale. One water molecule has a mass of 18.02 atomic mass units; one mole of water has a mass of 18.02 g. The first describes a single particle, the second a lab-sized pile of 6.022×1023 of them. Molar mass also belongs to the substance, not the sample: a raindrop and a swimming pool both contain water at 18.02 g/mol, though their masses are wildly different.
Think of it like this. Molar mass works like a unit price on a shelf tag. Cost is items times price, and mass is moles times molar mass, so dividing a bill by the unit price tells you how many items you bought, just as grams divided by molar mass gives moles. The formula sets the tag, whatever amount you weigh out.
Core idea. Molar mass, in grams per mole, is the sum of the atomic masses in a formula. Because a mole is a fixed count, it is the conversion factor between a mass you can weigh and the number of particles you have: n=m/M.