This is simply a protective mechanism of the body. A person with blood group A will produced antibodies against blood group B because group B cells are considered foreign bodies to the person and will not be tolerated and vice versa. Group B people have antibodies against group A and will not tolerate group A cells. This is why group A person can only be transfused with group A blood or group O blood. Both A and B have no antibodies against blood group O. Indeed no blood group has antibodies against Blood group and this is why people with blood group O are called universal donors.
Group AB people do not have antibodies against any blood group because both these groups are part and parcel of their body and production of antibodies against either A or B would end up in self destruction of the body. Group AB people are known as universal recipients because they can receive blood from any of the other groups.