Flies are just trying to survive and, inside your house, flies will land on your food, soda, dog food and many other things to get a tasty meal. Anything sweet will definitely attract flies.
Can houseflies smell? Yes, they do. When flies smell something awful, like a lot of trash lying around, they will assemble in your yard or your home.