Endocrinology is, at least etymologically, the study of hormones.
Diabetes doctors are endocrinologists because diabetes was historically thought to be all about insulin (I say historically because I think if we knew then what we know now about type 2 diabetes we might not classify it that way).
But not all endocrinologists are about diabetes. The endocrine system in the body has a number of parts: the gonads (ovaries, testes, or things that seem like they would have become ovaries or testes), the islet cell portion of the pancreas, the adrenal glands, the thyroid, the four parathyroid glands, and the pituitary gland.
Most endocrinologists fall into one of three categories: reproductive endocrinologists, who deal primarily with issues of infertility; metabolic endocrinologists, who deal primarily with diabetes but also with thyroid disorders and occasional pituitary, adrenal, and parathyroid disorders; pediatric endocrinologists, who deal with endocrine issues in kids, mainly diabetes, growth hormone deficiencies, adrenal hyperplasias, and thyroid diseases. A rare few endocrinologists actually specialize in thyroid disorders or adrenal disorders, or even endocrine cancers.
Endocrinology, diabetes, and metabolism is a specialty that a doctor gets after being an internist.
Reproductive endocrinology/infertility is a specialty that a doctor gets after being an OB/GYN.
Pediatric endocrinology is a specialty a doctor gets after being a pediatrician.
Many diabetics get their diabetes treated primarily by an internist, geriatrician, or pediatrician, or by somebody who's not a doctors such as a diabetes educator, nutritionist, or nurse. Or, of course, by themselves.