The eggs must be there already, they're the second stage of the life cycle of a fly.
You might be mistaking the eggs, from which the larvae hatch, for rice grains.
Where Do Maggots Come From?
Maggots come from the eggs of flies, and their lifecycle follows these steps:
Eggs: A female fly will usually lay around 150 eggs at a time. The eggs of flies resemble small grains of rice.
Larvae: Fly larvae refer to maggots, and they resemble small worms.
Pupa: The pupa stage occurs when the skin of maggots turns into a dark, protective shell much like a cocoon. During this phase, the bodies of maggots will transform into a fly. Before entering the pupa stage, maggots will go through a pre-pupa stage in which their bodies begin to form this protective shell.
Fly: Once the fly fully develops inside the protective shell, it will break free.