There are several factors, including number of cylinders, crank throw spacing(degrees) as well as how a manufacturer numbers the cylinders. A few things to consider, using a V-8 since that is the most discussed here, most V-8s have what are called 90* cranks so every 90* of rotation there is a cylinder at TDC. Now if you divide the 360* of rotation by 90 you see that there only need to be 4 pistons for a complete rotation of 360*. That means that in a V-8 there are 2 cylinders at TDC every 90*. One is ready for ignition and one 180* out from it in the ignition. That allows a firing every 90* and one of the reasons that V-8s are known for their smoothness incomparison to a staright 6. You could conceivably grind a cam and set the ignition so that 2 cylinders would fire simultaneously, creating more power per stroke but have a vibration that was not desirable. Oversimplifying you could say that the more cylinders an engine has (evenly divisible into 360) the smoother it will be. There have been all sorts of combinations used in various vehicles( mostly racing), but the production engineers are usually trying to create the smoothest operation with the number of cylinders in the engine. If you examine the V-6s based on cutting 2 cylinders off of a V-8 you will see that most modern ones are referred to as even fire and the crank is cast so that the firing pulses are even. Early ones, the Buick V-6 in particular, were odd fire. Basicly a V-8 with 2 cylinders removed from the crank and firing order. The Ford racing V-6 while based loosely on the production even fire V-6 is an off fire engine because they make more hp,but aren't as smooth. I remember some of the early Buick engines literally shook the guts apart in the distibutor.
Ther are many components of how a firing order is determined at the factory and this was to give a fairly brief synopsis of what is involved.