Markup is how much you add on top of your cost. If something costs you $100 and you mark it up 50%, you charge $150.
Margin is what percentage of the selling price is profit. That same $150 job? Your margin is 33.3%, not 50%. The profit ($50) divided by the selling price ($150) = 33.3%.
The formulas:
Selling price = Cost / (1 - margin%/100)
Margin% = (Selling price - Cost) / Selling price x 100
Markup% = (Selling price - Cost) / Cost x 100
A lot of contractors think they're making a 30% margin when they're really marking up 30%, which only gives them a 23% margin. Over a year, that gap adds up to real money left on the table.