So if you look at the periodic table, you have elements like potassium and calcium which have 4s electrons. Then afterward you go into the transition metals which have 3d electrons. So you do fill the 4s before the 3d. However, when you remove electrons, you need to remove the 4s electrons before the 3d electrons, since you remove from the highest principal quantum number first. (If they share the same principal quantum number you remove the one with the highest l value first, meaning remove 3p electrons before 3s electrons.)
So scandium is [Ar]4s(2) 3d(1) or you can rearrange it in energetic order afterward and put it as [Ar]3d(1) 4s(2). They mean the same thing. Now if you have Sc++, you actually have [Ar]3d(1) 4s(0) since 4s has a higher principal quantum number than 3d. It is confusing, but with practice you'll get the hang of it 👍
The principal quantum number refers to energy and therefore distance. The 4s orbital is further from the nucleus than the 3d orbital. Even though the 3d electrons don't penetrate well, they're still closer to the nucleus than the 4s electrons and are therefore not removed until the 4s electrons go away.