Why is my own immune system attacking my body? Did I do something to cause my diabetes?

Unclear. If you're talking about type one diabetes, the one when your body makes no insulin, then what probably happened was your immune system was exposed to something (maybe a virus) that looked to it like the cells in your pancreas. It then started mistakenly treating those pancreatic cells like an illness it needed to get rid of. Type 2 is something else entirely. Bottom line: you didn't cause it.
Autoimmunity. Autoimmunity is the failure of an organism in recognizing its own constituent parts as self, which allows an immune response against its own cells and tissues. Any disease that results from such an aberrant immune response is termed an autoimmune disease. The answer to your question is "no!" not your fault.