The rule is based on the square inch of the fish...Length being a contributing factor.
It works only for really small fish,
The "rule" applies to the cubic inches of fish in the tank.
This means that a 5" gourami should be measured in this manner,
length overall (5"),
height, (2 1/2"),
so for this fish you multiply the following, 5x 1/2x 2 1/2, this gives you a total of 6 1/4 gallons of water.
For small fish like glo-light tetras you will end up with something like this,
1 1/2"x 1/4"x1/2", this comes to 3/16 of a gallon (about 1/5), and that gives you 5 fish of this size per gallon (quite reasonable)
For larger fish you end up with something like this, my example here will be a silver Arowana
at 24" long, 24"x 4"x 1", which gives you 100 gallons of water.
As you can see this works fairly well.
You do also have to apply some common sense and allow for such things as potential growth, the fish types' tolerance for crowding, and of course the width and length of the tank (a 24" gar will not work in an 18" wide tank even if the tank holds 100 gallons).
It is a GUIDELINE to give a rough idea not a set "rule" as you would not keep an arowana that was fully grown in a 100g tank, it would not be able to turn around without hitting the side of the aquarium.