All atoms seek the most stable form, and having half full or a full d-orbital is pretty stable which leads to the 4s orbital losing one electron to the 3d-orbital because this is a more stable configuration.The small energy difference between 4s and 3d also leads to effects such as all oxidized forms of the d-block elements losing the s-orbital electrons first.