The 2 formulas are mathematically equivalent:
$\frac{\sum{(x_i - \mu)^2}}{n} =$
$\frac{\sum{(x_i^2 - 2 x_i \mu + \mu^2)}}{n} =$
$\frac{\sum{x_i^2}}{n} - \frac{2 \mu \sum{x_i}}{n} + \frac{n \mu^2}{n} =$
$\frac{\sum{x_i^2}}{n} - 2 \mu^2 + \mu^2 =$
$\frac{\sum{x_i^2}}{n} - \mu^2$
The first form requires you to loop through the data 2 times, once to compute the mean, then a second time to compute the variance (the square of the standard deviation). The second form can loop through the data 1 time calculating the sum of the values and the sum of the squares of the values, then combining them. The second is preferred when you only want to go through the data once (can give speed advantages for some big data cases), but the first is often less affected by rounding error, so both are still used.