Why do they come into your home?
House flies are attracted to many items that you might find around the house, including garbage, dirty dishes, and pet food. They also enjoy laying their eggs in moist garbage or sewage. When situations arise where they like to lay eggs, there will often be large numbers of them concentrated together. This is why you'll often see a bunch of them when you're near a garbage dumpster, but none in your home.
Image Credit: http://thisoldhouse.com
They are looking for somewhere to lay their eggs, and until they find the perfect spot they will stay around in large numbers searching for it.
Since flies can breed in low concentrations of organic waste, breeding areas do not have to be large either. This means that if even one fly gets into your house, it can quickly lead to an infestation, if the right precautions are not set.
It's also worth noting that adult flies only live for about 30 days at most before dying off, so just because you get rid of all the adults doesn't mean their offspring won't return later.