You are mixing descriptive statistics of a sample (such as $\bar X, S)$ with parameters of a population (such as $\mu, \sigma),$
and description of a sample with estimation of parameters.
Describing sample center or location.
The correct version of the sample mean of a sample $X_i, X_2, \dots X_n$ of size $n$ is $\bar X = \frac 1 n \sum_{i=1}^n X_i.$ Many authors reserve $N$ for the size of the population. The sample mean $\bar X$ is a descriptive statistic. It is one way to
describe the "center" of a sample.
Some alternative ways to describe the center or location of a sample are (a) the sample median, which is the middle value when data are sorted from smallest to largest (or halfway between the middle two values if the sample size is even), (b) the midrange, which is halfway between the largest and smallest sample values, and (c) the mode which is the value that occurs most often in the sample (if there is one such value).
If you have a sample of seven test scores (78, 96, 84, 92, 88, 75, 51), then R statistical
software gives the following summary of the data:
x = c(78, 96, 84, 92, 88, 75, 51)
summary(x)
Min. 1st Qu. Median Mean 3rd Qu. Max.
51.00 76.50 84.00 80.57 90.00 96.00
length(x); sum(x); sum(x)/length(x)
[1] 7 # sample size
[1] 564 # total of seven observations
[1] 80.57143 # mean (to more places than above)
sort(x)
[1] 51 75 78 84 88 92 96
min(x); max(x); median(x)
[1] 51 # smallest
[1] 96 # largest
[1] 84 # middle value of 7 sorted values.
The midrange (96 + 51)/2 = 73.5 is not given by summary
; this sample has no mode.
For small samples an effective graphical description may be the stripchart (or dotplot):
stripchart(x, pch=19)
For larger samples a boxplot or histogram (not shown here) may be used.
The choice whether to
use sample mean, sample median, sample midrange (or some other descriptive statistic) depends on the nature of the data
and on one's purpose in finding the center or location of the sample.
By contrast, $\mu$ denotes the population mean $\mu.$ So if you have a finite population of size $N$ with elements $X_i,$ then your equation (1) would be the definition of the population mean $\mu.$ [For a theoretical infinite infinite population specified in terms of
its density function $f(x),$ the population mean is defined as $\mu = \int xf(x)\,dx,$
where the integral is taken over the interval of all possible population values, provided that the integral exists. (For many of the distributions used in statistical work the population mean $\mu$ exists; Student's t distribution with one degree of freedom is a well-known exception.)]
Describing sample variation and spread.
The usual definition of the sample variance is $S^2=\frac{1}{n-1}\sum_{i-1}^n (X_i - \bar X)^2.$ [In a few textbooks the denominator $n$ is used.] The units of the sample variance are the square of the units of the sample. [So if the sample is heights
of students in inches, then the units of the sample variance are square inches.]
The sample variance describes the variation of a sample, A related descriptive
statistic for sample variation is the sample standard deviation
$S = \sqrt{\frac{1}{n-1}\sum_{i-1}^n (X_i - \bar X)^2}.$ its units are the same as the units of the sample.
Some alternative ways to describe the variation of a sample are the sample range (largest sample value minus smallest) and the midrange, which is the range of the
middle half of the data (upper quartile minus lower quartile). [There are still other
descriptions of sample variation; some are based on medians.]
For the sample of seven test scores above, the variance and standard deviation are
as follows:
var(x); sd(x)
[1] 224.619
[1] 14.9873
From the summary
above, the range is (96 - 51) = 45, and the interquartile range (IQR) is
$(90 - 76.4) = 13.6.$
diff(range(x)); IQR(x)
[1] 45
[1] 13.5
(A peculiarity of R is that range
returns min and max, so we get the usual sample range by subtraction.)
Estimation of parameters.
Depending on the shape of a population distribution, it may be appropriate to
estimate the population mean $\mu$ by the sample mean $\bar X,$ or to estimate
the population median $\eta$ (half of the probability on either side) by the
sample median. Also, it may be appropriate to estimate the population variance $\sigma^2$ by the sample variance $S^2,$ or to estimate the population standard
deviation by $\sigma$ by $S.$
Among many, a couple of criteria for a desirable estimator is that it unbiased
and that it have the smallest possible variance. Roughly speaking, this
amounts to ensuring that on average the estimator is aimed at the right target (unbiasedness) and that the aim is optimally precise (small variance).
This is not the place for a detailed discussion of estimation. However, it is
worth mentioning that, for normal data, $S^2$ as defined above is an unbiased
estimator for $\sigma^2,$ while the maximum likelihood estimator $\widehat{\sigma^2} = \frac 1 n\sum_{i=1}^n(X_i-\bar X)^2$, with denominator $n,$ has a downward bias, systematically underestimating $\sigma^2.$ Therefore many (but not all) statistics tests use $S^2$ (denominator $n-1)$
as the estimator of $\sigma^2.$ (Perhaps see this related Q&A.)
[As @Dave (+1) makes clear in his Answer, your equation (2), with $N$ in the denominator is the the formula for
$\sigma^2$ of a finite population consisting of $N$ possible values, for which the population mean $\mu$ is known.]