There are different type of immune cells which falls under either **innate** or **adaptive system**.
The cells under the innate are first to respond microbial attack and are able to detect them in extracellular environment by recognizing proteins/peptides called **Pathogen-associated Molecular Patterns (PAMPs)** on their surfaces; these are only found on microbes.
But when the innate system fails to clear the microbes in time, the adaptive system is kicked-in. This involves T-lymphocytes and B-lymphocytes. T-lymphocytes are trained to ignore cells that are able demonstrated that they self but B-lymphocytes which produces **antibodies/immunoglobulins** to the detected antigens do not have a mechanism of ignoring self cells.
So the problem lies with when the immune response gets to the point where antibodies are produced, at that point produced antibodies simply attack without discrimination.
I hope this simplified version would help you.