What factors affect the number of individuals in an animal group?
this depends on what you mean by group.

If you mean population then it is mostly environmental factors, although part of the environment can be other member of your species, some groups have a minimum functional size, such as passenger pigeons and breeding in groups behavior, or have density controls(if you are too spread out you might never run into another member of your species to breed with) , these internal factors are fairly rare however compared to basic resources availability, things like food, water, territory, shelter, nutrients, ect. 

If you mean size of individual packs, herds, ect, then it is a mix of both, behavior which is almost always genetic is the main cause. However this behavior can be alter or triggered by environmental factors and its ultimate evolution is strongly affected by those factors as well. for instance large herd behavior will never evolve if the environment cannot support it, and if the environment changes the behavior may stop being beneficial.