There is a variety of reasons. A change of structure within the government can happen in such a way that certain departments need to be reorganized. A deputy minister may retire and that can create a domino effect: he is replaced by someone and another vacant post must therefore be filled. In effect, a change to one deputy minister post generates other changes.
Changes can also occur because the government modifies its priorities and/or policies. A deputy minister may be deemed to have the required qualities and abilities to make the new issues progress or the new priority requires the hand of a different deputy minister, who is then appointed to shepherd the cause.
There is a variety of reasons.