What are the causes of stiffness after a total knee replacement?

Depends. Causes of stiffness following knee replacement include scar tissue formation, component size and position among many factors. However, the most important factor is the patient's preoperative motion (i.e. Preoperative stiffness is likely going to lead to less than optimal postoperative motions).
Depends on when. Early the causes are many, typically swelling and pain. After 3 months the major cause is scar tissue formation.
Scar tissue. Rehab after a total knee replacement is a race between the formation of scar tissue and achieving appropriate range of motion. Appropriate pain control is essential to help you win this race.