Backquotes are used when you need to use the results of a particular command inside another command or expression.
Looking at the first example, getAttr locator1.tz by itself would normally just return the TranslateZ value of locator1, print the results in the script editor and complete the command. The result is not usable at all.
Embedding the command within backquotes will make the results usable in an another command. In the case of the first example, the results of the command getAttr locator1.tz are assigned to the variable $locZ.