The best main way i find to avoid overstocking is to research how big the particular fish you want grows, the vast majority of fish sold in lfs(local fish stores) are not full grown and are usually only half grown at best- when most fish get to about a third grown they look exactly like their parents except from the obvious size difference, but if you have never seen the fish full grown before you could be forgiven for thinking the fish you are buying is already full grown and will not outgrow or overstock your tank. Many fish like common and sailfin plecs for example are sold at only a few inchs long but can easily get to 2ft long given a couple of years.
The inch per gal rule is a good rule but should only be roughly applied as a rule of thumb when first researching what fish are available to your tank size and should only be used taking into consideration how big the fish will get and not what it currently stands at, there are also many exceptions to this rule i.e;
a. If you used the rule straight forward it would mean you could have 10 1inch neon tetras or a 10 pleco in a 10gallon tank max- of course this is not true. Neon tetras are very small waste producers and so you could get away with 13 or so in a mature 10gal tank, but a 10inch plec on the other hand would barely be able to turn around in a 10gal tank and plecs produce alot of waste so a 10inch plec for a 10gal tank would be an absolute no-no.
b. The 1inch of fish per gal stocking rule only applys to mature tanks and most tanks aern't fully mature til about 6months old, if you were to put 5guppys in a brand new tank although it would seem they would have enough space but the filter would not be able to cope with the sudden waste load and you would expect to see a ammonia spike and lots of sick fish.
c. Other things to take into consideration when stocking are the fish's aggressiveness, activity/how hyperactive it is and body shape and size- some expamples would be...;
c.i. Tiger barbs do not grow very big but need fairly large tanks due to their agressiveness towards each other and other fish, for agressive fish you need to consider the more space they have the more likely they are to get along and the more likely any picked on fish are to get away from their attackers/bullys- for 10 tiger barbs you are looking at atleast a 30gal tank.
c.ii. Danios have a reputation(which they live up to) for being very hyperactive fish and if you have a group of them you will always see them darting around the tank and never stopping. Because they are so hyperactive they need as much space as posible and a 20gal tank is the minimum size tank for any average sized danio however small your group of them is.
c.iii. the shape of your fish is also very important when taking stocking into consideration, black khuli loachs can get up to 5-6inchs long so for a group of 4 you would think they need at least a 25gal tank, but they are very slim-bodied eel like fish that produce very little waste and a 12gal tank is acceptable for a group of 4. Angel fish on the other hand are very tall growing fish and the height of the tank is one of the most important things for them as they like alot of depth in their tanks, 30gals deep is usually the minimum for them but for most other fish, length of tank instead of depth is more important to take into consideration.
Strength of your tank filter is also important to take into consideration as aquarium fish are essentialy living in their own toilet and the beneficial bacteria in the tank filter is the only thing that can remove things like ammonia caused primarily by fish poop, so for large waste producing fish like pleco's, getting a filter than can handle a much larger tank than your current one is important in making sure the filter is never going to struggle with the tank bioload etc.
There are many other things to take into consideration but this is the jist of things, happy stocking

.