Knowing what causes fruit flies is the key to eliminating them. Not many people would normally care where fruit flies came from, unless they had them in their home and were trying to get rid of them. In a nut shell, anything that is fermenting will attract these tiny flies. This includes fruits, vegetables, anything moist like mops and dirty rags, and of course alcohol. These are known as breeding places for fruit flies. They can smell something fermenting from very far distances away.
If you have anything like this in your home, they will be drawn in. Fruit flies originally come from out side, but will quickly make a new home for themselves in your home if you're not careful, especially if there is a change in temperature and it begins to get colder outside. Once they find the perfect spot, the can lay up to 500 eggs, in which those eggs, in a few hours, transition into adult fruit flies. The fruit fly only has a 10 day life span, so they develop extremely quickly from the egg to the larva and then ever the adult fly.
This is why you one day had only a few flies around, and then the next day, there are hundreds! Multiply this scenario by 500 and you can easily see how an infestation can occur. It can happen very fast, so the quicker you can eliminate them the better. Once you know what causes these pests, and where they breed, you can start focusing on those areas when you begin your eliminating process. Getting rid of their breading spots will help decrease their ability to reproduce, and make it easier for you to rid them from your home.