firstly, it's not a rule, it's a guideline
it goes a little something like this - you can stock 1" of small slim bodied fish per US Gallon of water in the tank. So if for example your tank is 25 US Gallons you can have 25 small fish like tetras or rasboras each reaching around 1". Obviously people will generally want more than one species so you compile a list something like this
2 rams - 3" each - 6" total
6 neon tetras - 1" each - 6" total
6 albino cories - 2" each - 12" total
Total - 24" of fish, so that a suitable beginners stocking on that size tank.
Now it's far from infallible, it doesn't work when you get onto larger fish and there are a lot of fish with specific requirements so they don't fit into the scheme above. Also it's not a hard and fast rule, if you go a few inches over or under it won't matter, when the tank is mature and you are experienced people often stock to more like 1.5"/2" to a US Gallon of water.