Electron configurations are derived from Atomic Models... The Bohr (Concentric Ring) Model specifies electron configurations with respect to the number of electrons per 'major' energy levels... That is, for any given energy level, the maximum number of electrons a major energy level can hold is given by the expression 2n2 => n=1 => 2(1)2 = 2e- max; n=2 => 2(2)2 = 8e- max; n=3 => 2(3)2 = 18e- max; etc... For any given element, electrons are added into the n = 1 first, then n = 2, n = 3; etc. Such gives the (2,8,8,2) configuration for element #20 (calcium) ... Adding electrons beyond At. No. 20 fills in the n = 3 energy level until 18 total electrons are placed then n = 4 in the 4th row is completed with 8 electrons, then n=5 and so on.
For the orbital electron configurations, the notations describe electron configurations for the Schrödinger Quantum Model. The filling scheme is defined by The Aufbau Principle which states 'In the building up process of the atom's electron configuration, electrons enter at the lowest available energy level'. Such follows, in general, the order-of-filling scheme known as the Aufbau Diagram. Example, [N]1s22s22p3 and so on... Whew! Borek's right, this can run into a day long lecture... Suggest searching history of atomic models... You should find some good treaties on the evolution of electron configurations.