I have two formulas for estimate of a slope in the simple linear regression model $y=\beta_0+\beta_1 x+\epsilon$:
$\hat{\beta_1}=\frac{\sum_{i=1}^N(x_i-\bar{x})(y_i-\bar{y})}{\sum^N_{i=1}(x_i-\bar{x})^2}$
$\hat{\beta_1}=(X_{1\times N}'X_{N\times1})^{-1}X'_{1\times N}Y_{N\times 1}=\frac{\sum_{i=1}^Nx_iy_i}{\sum^N_{i=1}x_i^2}$
These formulas are not equivalent, but are used in different literature as a main formulas to find the estimate of $\beta_1$. When we use each formula? what is the motivation to use averages of x's and y's in the first formula?
Second part of my question.
If I want to find a variance of $\hat{\beta_1}$ from the first formula $$Var(\hat{\beta_1})=\frac{\sum_{i=1}^N(x_i-\bar{x})^2Var(y_i-\bar{y})}{\big[\sum^N_{i=1}(x_i-\bar{x})^2\big]^2}=\frac{(\sigma^2-\frac{\sigma^2}{N})}{\sum^N_{i=1}(x_i-\bar{x})^2}$$ but the answer should be $$\frac{\sigma^2}{\sum^N_{i=1}(x_i-\bar{x})^2}$$ Where is my mistake?