why they have used z = (x bar - mu)/(sigma/sqrt(n)) rather than z = (x bar- mu)/sigma

In the following chapters, they are denoting it as the test statistic. What is the difference between standardizing and determining test statistic? The calculated z value using both formulas use z table. Which one will be applicable in which situation?