What causes a body part to swell when there is an injury or an infection?
A complex biological mechanism, which begins with the release of chemicals at the site of injury. This attracts white blood cells to the area, makes the local circulatory system a bit leaky, and that results in fluids and cells leaking outside into the tissue to fight infection and repair damage.
A very simplistic summary, and as a result not perfectly correct, but good for basic enlightenment purposes.
QtM, MD