It's the same way like humans are able to produce anti-human antibodies. Every organism can build antibodies against foreign antigens they are exposed to. When you have "antigen x" and you get pregnant or a blood product with "antigen z", your immune system may produce "anti-human z" antibodies. In this case, it's called allo-antibody. When your immune system produces antibodies against you own antigens, it's called auto-antibody. You see, antibody-formation is not only restricted to the exposure to other species.