In order for two gears to mesh, they need to have the same size and shape teeth on the same spacing.
As shown in the example above only one of the larger gears would correctly mesh with the smaller gear. It is said that these gears have the same pitch.
As seen above, for gear of the same pitch, tooth count and diameter are directly proportional. More teeth = bigger diameter.