Compost attracts! It attracts insects, including flies. Why, because they will lay where the larvae can feed. Indeed, the transformation of what we put in the compost, is done thanks to a set of living beings, some being microscopic, others larger.
Insects, larvae, spiders, worms of all kinds, crustaceans (woodlice) seek to feed. The adults lay where food is plentiful for the offspring. And thanks to this state of affairs, the animals in the compost participate in the decomposition of animal and vegetable matter. They transform them into a matter, compost, rich in humus which happens to be, in short, food for plants.
So it is normal, and even desirable, that the compost be inhabited. Fungi also play a crucial role in this transformation by mainly attacking brown, ligneous, wood-containing and carbon-rich materials. The compost teems with life. Visible and invisible to the eye. Bacteria and protozoa are part of it.
On the other hand, if you compost meat products, meat and fish, you will have a lot of flies, which can be unpleasant, I agree. But who says fly, says, larvae. We go back to the beginning.
To get out of it, you will find composting techniques by clicking on the link.
Valuing your waste is not technically complicated but requires know-how that you will quickly acquire by browsing the various articles on this blog.
Thank you for your question and your loyalty.