You can't rely on the ordering of a selection or an entities collection.
Also you should never 'loop' through a selection or an entities collection, IF your code will affect the selection or collection - since it's references will 'shift' - use .to_a to free it as an array if you must do this...
If you are adding several faces you make a simple empty array at the start:
faces = []
Then every time you make a face you can add that into that array.
... face = ... faces << face ...
Later on you can access the faces array and its ordering will remain constant.
You can only add geometry into an entities context - so that's either the model.entities [the lowest base level - even if not currently active], model.active_entities [current active context - which might be any collection], or any group.entities or definition.entities ...
In passing, a group is just a special subset of a component.
They both have a definition [so does an Image, but we'll not go there yet].
A definition can have instances - placed into some entities context.
A component definition can have several instances - changing one changes the others.
You can make an instance unique so that editing does not affect its relatives.
A group definition can have several instances, BUT editing one of them automatically makes it unique.
When iterating a definitions collection you can filter its members using defn.image? and defn.group? to choose or avoid those types...