Each row on introduces a new value for the principal quantum number ##n## while ##l## goes as ##0 1 . . . n-1##.
Recall that ##l = 0 -> s## orbital and ##l = 1 -> p## orbital. Therefore we would have these orbitals available:
##Row 1:## ##1s##
##Row 2:## ##2s 2p##
##Row 3:## ##. . .##
##Row 4:## ##. . .##
Carbon has access to only ##n = 2## and ##n = 1## so its six electrons can only go into the ##1s## ##2s## and ##2p## orbitals from lowest to highest energy (Aufbau Principle) one at a time to maximize spin (Hund’s Rule) with opposite spins when pairing up (Pauli Exclusion Principle).
##1s^2 2s^2 2p^2##:
##color(white)([(color(black)(ul(uarr color(white)(darr))))(color(black)(2p_x))]) color(white)([(color(black)(ul(uarr color(white)(darr))))(color(black)(2p_y))]) color(white)([(color(black)(ul(color(white)(darr) color(white)(darr))))(color(black)(2p_z))]) ##
##color(white)([(color(black)(ul(uarr darr)))(color(black)(2s))])##
## ##
## ##
##color(white)([(color(black)(ul(uarr darr)))(color(black)(1s))])##
If you want to read more on it:https://socratic.org/questions/how-do-you-draw-electron-orbital-diagrams