It may seem strange but the basis of the statistical analysis for analysing frequency data is the z score. The simplest way to view the 2 statistic is as the square of the z statistic:

2 is the square of the deviation of a score from its population mean divided by the population variance. Imagine the values of a normal distribution being squared: this produces a 2 distribution. 2 being a squared value is always positive. As large negative values when squared will become large positive values, we are only interested in the high values of the 2 distribution and it is always a two-tailed test as both a large positive z score or a large negative z score both square to a large positive 2. The ‘score’ we are interested in here is the count or the frequency of a particular category. We are interested in frequency counts within categories rather than scores within samples.