There's a really good paper on this, Moreau et al., worth reading through entirely. The only caveat is it was published in 2013, so as a rapidly evolving field such as immunology we might have more insight now. However, the general concepts remain the same.
The lymphocyte compartment that we generate in our own bodies is modulated so that it isn't autoreactive. In other words, for every antigen a T cell should expect to actually encounter in vivo, the ones that attack and kill self cells are made to undergo apoptosis, the special case of course being autoimmunity, which is a set of diseases.
An organ transplant is what's known as a so-called allograft. The allo- prefix implies that the origin is the same species, but from different individuals. So how do people differ at the molecular level? Well for one, we inherit and develop slight differences to such things as protein sequences, carbohydrate chain moieties, and certain receptor combinations. So, your lymphocyte compartment may be non-autoreactive, but it could be alloreactive because those aren't your signals.
The other thing transplants do is cause damage and inflammation that result in the presence of these patterns that the innate immune system respond to called PAMPs and DAMPs, or molecular patterns associated with pathogens and tissue damage. They also bring along donor immune cells like antigen-presenting cells, resident lymphocytes, granulocytes, etc. It's also a functioning tissue, and so just like any of your own cells, a liver cell is expressing class-I HLA loaded with alloantigens. This can have two effects: graft-versus-host, so you have donor immune cells attacking the recipient, and the rejection which is where your recipient immune cells attack the transplant.
Your immune cells attack the transplant predicated on direct and indirect recognition, and the fact that all that inflammation already has the immune system up in arms. So your lymphocytes recognize an alloantigen on the donor antigen-presenting cell is an example of direct recognition. This can occur in the transplant, and also in the recipient lymph nodes as donor APCs can traffic there on signals in the lymph. Recipient APCs can also pick up on alloantigens from donor cells and active the adaptive immune response classically, which would be an indirect recognition.
The blanket treatment for this seems to be immunosuppressive therapy.