There is an explanation to this that can be generalized, which dips a little into quantum chemistry, which is known as the idea of pairing energy. I'm sure you can look up the specifics, but basically in comparing the possible configurations of Nb, we see the choice of either pairing electrons at a lower energy, or of separating them at higher energy, as seen below:
d: ↿ ↿ ↿ _ _ ↿ ↿ ↿ ↿ _ ↿ ↿ ↿ ↿ ↿ ^
OR OR |
s: ⥮ ↿ _ Energy gap (E)
Hopefully you're following, the top row is for the d-orbitals, which are higher in energy, and the bottom row is for the s-orbital, which is lower in energy. There is a quantifiable energy gap between the two as denoted on the side (unique for every element). As you may know, electrons like to get in the configuration that is lowest in energy. At first glance, that might suggest putting as many electrons in the s-orbital (lower energy) as possible, and then filling the rest in the d-orbital. This is known as the Aufbau principle and is widely taught in chemistry classes. It's not wrong, and works most of the time, but the story doesn't end there. There is a cost to pairing the electrons in the lower orbital, two costs actually, which I will define now:
Repulsion energy: Pretty simple, the idea that e- repel, and having two of them in the same orbital will cost some energy. Normally counted as 1 C for every pair of electrons.
Exchange energy: This is a little tricky, and probably the main reason this isn't taught until later in your chemistry education. Basically (due to quantum chemistry which I won't bore you with), there is a beneficial energy associated with having pairs of like energy, like spin electrons. Basically, for every pair of electrons at the same energy level (or same orbital shell in this case) and same spin (so, if you had 2 e- in the same orbital, no dice, since they have to be opposite spin), you accrue 1 K exchange energy, which is a stabilizing energy. (This is very simplified, but really "stabilizing energy" is nothing more than negative energy. I hope your thermodynamics is in good shape!) The thing with exchange (or K) energy is that you get one for EVERY pair, so in the case:
↿ ↿ ↿
from say a p-subshell, you would get 3 K, for EACH pair, while from this example:
⥮ ↿ ↿ ↿ ↿
from a d6, you would get 10 K (for each unique pair, and none for the opposite spin e-)
This K is quantifiable as well (and like the repulsion energy is unique for each atom).
Thus, the combination of these two energies WHEN COMPARED TO THE BAND GAP determine the state of the electron configuration. Using the example we started with:
d: ↿ ↿ ↿ _ _ ↿ ↿ ↿ ↿ _ ↿ ↿ ↿ ↿ ↿ ^
s: ⥮ OR ↿ OR _ |
PE: 3K + 1C 6K + 0C 10K + 0C Energy gap (E)
You can see from the example that shoving 1 e- up from the s to the d-subshell results in a loss of 1C (losing positive or "destabilizing" repulsive energy) and gaining 3K (gaining negative or "stabilizing" exchange energy). Therefore, if the sum of these two is greater than the energy gap (i.e. 3K - 1C > E) then the electron will indeed be found in the d shell in Nb's ground state. Which is indeed the case for Nb.
Next, lets look at perhaps exciting the second s e- up to the d-subshell. We gain 4 additional K but don't lose any C, and we must again overcome the energy gap for this electron to be found in the d-subshell.
It turns out that for Nb: 4K + 0C < E (remember that C is considered a negative value, which we're not losing any of), so Nb is ultimately found in the 5s1 4d4 configuration.
That was really long, if you have any questions, leave them in the comments below and I'll try to answer them :D