How did Gauss conjecture there were nine Heegner numbers?

The first answer is that he did not. Gauss worked with binary quadratic forms with even middle coefficient (the determinant of a form $Ax^2 + 2Bxy + Cy^2$ is $B^2 - AC$), so some of his class numbers actually are ring class numbers modulo $2$ (equal to $3h$, where $h$ is the usual class number). In the Disquisitiones (art. 303) he gives a list, of which I give an extract here:

$$ \begin{array}{c|l} h & {\rm determinant} \\ \hline 1 & 1, 2, 3, 4, 7 \\ 3 & 11, 19, 23, 27, 31, 43, 67, 163 \end{array} $$ It is of course easy to transfer this to our usual class numbers, which is where the nine value up to $163$ are coming from. In Gauss's case, proving that there are only finitely many determinants with Gauss class number $1$ is actually quite easy; the difficult part is showing that those with Gauss class number $3$ are finite.

Gauss also observed that there seem to be only finitely many determinants with given small class numbers.

In addition to computational evidence Gauss also knew that the class number of his forms grows asymptotically as $$ \gamma \sqrt{D} - \delta, $$ where $\gamma = 2\pi/7e$ and $\delta = 2/\pi^2$ (art. 302).


Gauss had plenty of computing power. He calculated class numbers up to 2000, and found they got scarcer as he climbed higher, with none at all after 163. That seemed enough to conjecture there weren't any more.

Gauss was working with quadratic forms, rather than quadratic fields, and the bigger the discriminant, the easier it was to find inequivalent forms, so it stood to reason that eventually there would be no discriminants with just one class of forms.