Standard Deviation - Different way to get value?
So I learned that standard deviation is as such that if there is a set:

with the average:

Then the standard deviation is:
^2 + (x_2 - a)^2 + ... + (x_n - a)^2}n })
But a while ago, I was told that this works too (and I checked it, and it seems to work):
If given the set:

with the average

and the average of the square of each
:
^2}n)
then the standard deviation is as follows:

Why is it that the second way of getting standard deviation right? In other words, how do I derive the second way from the first way? The main reason I am having trouble figuring this out is that it seems to make the assumption that:
^2}n = \frac{(x_n)^2}n - a^2)
Which if I recall correctly, is not true because:
^2}n = \frac{(x_n)^2 - 2ax_n + a^2}n)