Allele frequencies determine expected genotype frequencies under the Hardy-Weinberg model.
Counts determine allele frequencies
From genotype counts AA=9, Aa=12, aa=4, the allele frequencies are p=3/5 and q=2/5.
p=53,q=52
Hardy-Weinberg predicts genotype frequencies
With those allele frequencies, the equilibrium table sums to 1.
p2+2pq+q2=1