This question already has an answer here:
According to Aufbau's Principle energy of 3d orbital is greater than 4s orbital, so which filling 4s if filled beforehand 3d. Whereas while removing electrons 4s electrons are removed first. Why?
I somewhere read that Aufbau's Principle is true only for ground state. When both 3d and 4s orbital get populated due to some interaction 3d shell is raised a to higher energy level than 4s. It it the case or it has some other explanation.