Typically administrators are appointed because there was no valid will left by the deceased.
Yet there are some cases where there is a valid will and an administrator. This can happen if the will names no executor or the named executor refuses to act, is incompetent, or denied by the judge.
The image on this post comes from the appointment of an adminstrix when my ancestor’s 1877 will named no executor. His wife was appointed “Administratrix with the will annexed” as shown here.
Another situation is where the executor dies before the estate is settled. A great-grandmother was settling her husband’s estate and died before it was settled. In her case, she appointed her executor to also complete the settlement of her husband’s estate.