There are mainly two types of diabetes
It is an autoimmune disorder. A combination of genetic predisposition and some other factors incite the immune system to attack the insulin-producing cells of the pancreas.
It is occurs due to insulin resistance, which means that the body is not able to utilize the insulin made by pancreas how it should, hence glucose does not move out from blood into body cells. After a while, the excess built-up of sugar in the blood starts creating a problem for pancreas itself making it produce less insulin.
Increased levels of certain female hormones during pregnancy hamper the ability of insulin to manage sugar and leads to insulin resistance.