Hi,
It is not known how to prevent type 1 diabetes.
It is believed that type 2 diabetes can be prevented or at least it's onset delayed with lifestyle measures.
Diabetes type-1 is due to destruction of insulin cell means the body get deficient of insulin, in this case the amount of the blood sugar rises. It can be prevented.
Diabetes type-2 occurs when the body is not able to use insulin in appropriate manner. It can be prevented with healthy lifestyle.
To put it simplistically, the root cause of Type 1 is autoimmune. The pancreas beta cells that produce insulin are destroyed and can no longer produce insulin.
For type 2, the root cause is insulin resistance. The pancreas produces plenty of insulin, but the insulin doesn't work properly.
For type 2 weight loss may help to reverse insulin resistance.
Exercise is very beneficial for both types, along with lower carb diet.
Hope this helps.