To understand their relation, you should go back to how $\sigma^2$ is defined. Recall that in the discrete case
If you have have all observations in the population, you can calculate this expected value by the formula you first provided
When $X$ instead is a random variable, with a probability $p$ of occuring, you have the following formula
For the binomial case this is equal to
Rewriting this term, will in fact give us the resulting
For a proof of this, just google binomial variance proof. In summary, the formula you first provided is the formula for calculating the population variance. The second formula is how you calculate the variance of a random variable that has a binomial distribution.