The flies would have been attracted to something (a dead animal/rotting food etc) - they seek out a protein source to lay their eggs on so that the young maggots have plenty of food when they hatch.
The life cycle of the fly is the same as that of a butterfly - adult/pupa/larva(maggot in this case).
One adult femal fly will lay hundreds of eggs and these will hatch within hours if it is warm, resulting in hundreds of maggots!! If left to their own devices the maggots will feed for about a week, then pupate and emerge as adult flies around a week after.
I used to breed flies for a living (I'm a biologist)!
Removing anything that will attract the flies will sort out your maggot problem : )