Dense-layer parameter counts are exact integer formulas. The toy network is a small instance of the same formula.
Dense-layer count
For a dense layer, each output has one weight for every input and one bias. The exact formula is output dimension times input dimension plus one.
params=dout(din+1)
Recompute the toy
For the hidden layer, 2 times (2 plus 1) equals 6. For the output layer, 1 times (2 plus 1) equals 3. Together they equal 9.
2(2+1)=6,1(2+1)=3
Summary
Parameter counts are exact integer arithmetic. The problem is not that the formula is mysterious; the problem is how quickly the counts grow.
exact formula; growing count