The days when most of the fish for freshwater aquariums came from the wild has gone. This is good as it means the freshwater stocking industry is generally self sustaining, and wild stocks are mainly left intact. The fish are bred in large commercial breeding facilities and also by hobbyists.
This situation cannot have come about overnight. There has to have been experimentation, failures, and much time. It got there though. I remember reading an article about the neon tetra and how excited and overjoyed the aquarist was when they first bred.