You refer to markup pricing and margin-based pricing, which are distinct pricing strategies.
In margin-based pricing, we're concerned about the difference between the product's selling price and its cost.
$\frac{(P_{selling} - P_{cost})}{P_{selling}} = 1 - \frac{P_{cost}}{P_{selling}}= Margin_{percent} $
$ 1 - Margin_{percent} = \frac{P_{cost}}{P_{selling}} $
$P_{selling} = \frac{P_{cost}}{1 - Margin_{percent}}$
Which relates to your second calculation of 'profit'.
Your first calculation is the markup, which is a fixed percentage of the cost.
When it is appropriate using each pricing strategy seems to be a business management question, which is briefly discussed here