It's actually the other way around. The rule is 2 gallons of water per 1 inch of goldfish, not 2 inches of goldfish per gallon.
I mixed up my numbers. Even then it's not a reliable stocking method. Inches per gallon is never a good idea to use because fish grow in three dimensions not just one. And fish continuously grow throughout their lives. People who stock koi ponds with this method often end up culling fish at the end of the summer because the pond becomes overstocked.