How many fish can I have per liter in my aquarium, or how much water should I have for each fish?
When determining the capacity of an aquarium, it is common to look at total fish length rather than number of fish. The idea is that bigger fish need more room. The rule-of-thumb I've always used for freshwater tropical fish is 1 inch of fish length per gallon of water (or about 25 mm of fish length per 4 liters). However, this can vary greatly based on the species of fish. Some fish need more room than others.
There are some rules of thumb and even stocking calculators out there that you can use to get a rough sense of what works, but every new tank setup could use a bit of research. There's a lot of complexity, but there's also a lot of experience out there, and it's always a good idea to get feedback on your stocking and setup plans.
You have to consider, basically, the capacity of your system to handle waste vs. the capacity of your animals to produce it, and like the other answers say, there's no simple fish:volume formula that Just Works. It depends on a lot of factors: the type of fish, the type and capacity of your filtration, your water quality (both from the tap and once the tank has matured), how many and what kind of plants you have, etc.
You also have to consider how compatible the animals are. There might be fish that are fine for your tank in terms of bioload, but are extremely territorial and wouldn't have enough space to stay out of sight from each other. On the flip side, some (like the tetras you mention) do best in schools and may experience high stress and aggressive behavior on their own -- and some schools of fish might need a lot of open room to cruise in. You also want to look out for combinations of species with such different water quality requirements that you can't find a healthy point for both of them at the same time.
Also, it's not as big an issue for the tetras you mention, but always plan for the adult size and behavior. You hear horror stories about people stocking things like red-tailed catfish or arowana in their 10-gallon because it was only a few inches long at the pet store...
There is no general rule of thumb and it depends on the fish you plan to keep. Some fish can live in small volume of water while some need larger roaming areas. For example: Oscars/Flowerhorns require at-least 40 gallons per adult/semi-adult fish while African Cichlids are suggested to keep in a dense pack to reduce their aggression.
As for tropical fishes (guppies, tetras etc), you should aim for a gallon of water per inch of fish.
This is an older question but one more thing to think about, related to toxotes's answer, is about the space requirements of a fish irrespective of other tankmates. Yes, on one hand we have to consider the waste they produce, the water volume, and the filtration to deal with the waste.
Beyond that, though, fish have different needs/wants for room to move. Poor swimmers can be in a much smaller tank than an otherwise similar fish that naturally swims well. Many common schooling fish, like several popular tetra species, are accustomed to having a vast area of potential places to swim and explore. To be clear, they require open spaces; it's one of the reasons that in many setups it is best to have only one schooling species even if it seems that biologically you could handle more than one group. Each of them occupies space the other would like to know is open for future use. And when you think about stocking, adding one fish to an existing school entails much less additional required space than adding a new species altogether.
With that in mind, the parts of the tank a fish occupies is worth thinking about as well. Neon tetras and corydoras (other than pygmy and hastatus species, which do not spend all their time on the bottom) do not compete for space. Cichlids and many schooling species don't much care about the very top of the tank and would therefore be unbothered by fish like hatchets that spend the vast majority of their time at the surface. If you were thinking about keeping mostly bottom-dwelling species, then you could stock quite a few more in a 20 gallon long tank than a standard 20 gallon due to the greater square footage on the bottom.
Remember that you're providing the fish's entire world. The tank they are in is all they will know. We can't give them the size and complexity of their native habitats, but that's no reason not to do our best to give them an adequate environment. Even fish like the betta—who many like to say live in very shallow, "puddle"-like waters—have thousands of gallons to roam in their native lands in spite of the shallow depth. With that said, the reason we are more open to keeping fish like the betta in small tanks is because the mass-bred (and especially the long-finned) varieties are not good swimmers.