The subshells can have energies close to an other. For instance at carbon, 2s and 2p can both provide electrons to bonds, and accordingly, carbon can have the valences 2 and 4 usually.
p6 uses to be stable and not to participate in bonds. Note that it's not a full shell: it would have been [Ne]3s23p63d10 which doesn't even exist, while Ne [Ne]3s23p6 is a noble gas. And I write "uses to" because heavy noble gases make stable compounds with F for instance.
The varied shells have subshells with energies interleaved, and for instance 4s fills at K and Ca before 3d at Sc. The "Aufbau" predicts the filling sequence with some success by ordering the subshells by energy, with exceptions like Cr and Cu. But as the energies are close, and the electrons interact, several subshells can participate in bonds, and they give an element many different valences.
Ag is rather simple, but the transition elements are a mess because of that.