when to use which z score equation?

Solution 1:

It is the difference between the $z$ score for a datum from an entire population and a sampling.

The $z$ score for a datum $x$ is $z = (x - \mu)/\sigma$ where $\mu$ is the population mean and $\sigma$ is the population standard deviation.

If the datum $x$ is not from the entire population but rather from a sampling from that population then the standard deviation is divided by the square root of the sample size $n$.

Solution 2:

The $z$-score calculation is designed to answer the question: "How far from typical is this result?"

When dealing with a single datum, the single-value formula $z=\frac{x-\mu}{\sigma}$ gives us the answer. But when dealing with a whole pile of individual measurements, we expect the Law of Large Numbers, and its more formal cousin the Central Limit Theorem, to take over: more attempts means the mean of our results is going to look more like the population mean. To model this, we divide the usual standard deviation by $\sqrt{n}$: $z=\frac{\bar x-\mu}{\sigma/\sqrt{n}}$.