The most likely reason that fabric and pantry pests are inside your home is that they came in on something already infested with their eggs or larvae. Food purchased from the store is a regular culprit of a pantry pest infestation. Fabric pests are often brought inside on things like used furniture, clothing, boxes, and rugs.
Sometimes adults will find a way into your home on their own, common with fruit flies. When fruit flies live outside in your gardens near your home, it is easy for them to fly inside through open windows and doors. Once inside, the adult females will lay their eggs on top of fermenting liquids, ripe fruit, vegetables, or debris in clogged drains.