Before you can trust the sentence "4s fills before 3d," you must know what the tiny symbols n, l, s, p, d, and the pictures behind "orbital," "shell," and "energy level" actually mean. This page builds each one from zero, in the order that lets the next one make sense.
Look at the figure: the amber dot at the centre is the nucleus. The cyan cloud around it is one orbital — denser where the electron spends more time. Why we need this picture: the whole topic is about which cloud an electron picks. If you imagine neat rings you will be misled; clouds have different shapes and different distances, and both matter for energy.
Why the topic needs n: it is the first ingredient of the price tag. The parent note's whole debate ("is it 4s or 3d?") is a debate about how much n alone decides.
Distance is not the whole story, because clouds of the same floor can have different shapes. That shape is labelled by a second number.
Look at the shapes:
s (l=0): a round ball centred on the nucleus.
p (l=1): a dumbbell — two lobes with the nucleus pinched in the middle.
d (l=2): a four-lobed clover.
f (l=3): even more lobes.
Why the topic needs l: it is the second ingredient of the price tag. The letter tells you the shape, the shape tells you the penetration, and penetration is why l shows up in the Madelung sum.
Each orbital shape actually comes as a small set of clouds (called a subshell), and there is a fixed number of seats.
Check every case in the figure:
s: l=0⇒2(2⋅0+1)=2 electrons.
p: l=1⇒2(2⋅1+1)=6 electrons.
d: l=2⇒2(2⋅2+1)=10 electrons.
f: l=3⇒2(2⋅3+1)=14 electrons.
Why the topic needs this: to write a configuration like 2p6, you must know the "6" — the superscript is exactly this capacity. How electrons spread out among the orientations before pairing is Hund's Rule.
The order in which these labels are written (filling order) versus the order electrons are removed is a separate question handled by Ionization and Electron Removal Order, and the few places the neat pattern bends are in Electron Configuration Exceptions (Cr, Cu). The blocks of the periodic table are literally these labels laid out in a grid — see Periodic Table Blocks (s, p, d, f).