Antibodies and antigens are made out of proteins. Proteins have a specific primary structure. The primary structure is the sequence of the amino acids that make up the protein. This sequence is specific to a certain protein. Due to the primary structure the proteinseither folds into an alpha helix or a beta-pleated sheet, which is called the secondary structure. The protein then folds into a globular structure which is the tertiary structure. The globular shape of the protein depends on the primary as well as secondary structure and is specific.
Now we have over 10,000 antibodies in our bodies and they have different primary and secondary structures and, therefore, different shapes. An antibody is y-shaped and has a binding site which is specific to a specific antigen. So if an antigen comes along, it cannot bind to all antibodies but only the ones that have a complementary binding site to the shape of the antigen which makes it specific and is due to the protein structure. We do not attack our own antigens because we do not have any antibodies that are complementary to our own antigens. (Also it could happen if we get injected a blood group that we do not belong to)