Why do my legs swell?
You could think of this as a plumbing problem, with narrowing of the pipes (pulmonary arteries) causing increased resistance to the flow of liquid (blood), and high pressures building up behind that point. In pulmonary hypertension, the high pressure in the pulmonary arteries is transmitted backwards through the right ventricle (recall that blood flows from right atrium → right ventricle → pulmonary arteries). In response, the right ventricle typically stretches and then thickens over time. If the high pressures persist, eventually the right ventricle can no longer adapt and pressure will start rising, first in the right atrium and eventually in the veins that normally return blood to the heart.
The veins of the legs are particularly vulnerable to pressure building up for two reasons. First, they are furthest from the heart so the blood has a longer way to travel to return to the heart. Second, the legs spend most of their time below the level of the heart. Therefore, the veins have to do more work against gravity to return the blood to the heart.
Leg swelling is usually due to excess fluid leaking out of blood vessels and building up in the soft tissues of the leg. Medically we call this fluid "edema." Normally, any fluid that leaks out is picked up and drained by the veins in the legs and is eventually returned all the way to the heart and into the right atrium. However, when pressure rises in the right ventricle and right atrium and then backs up into the veins of the leg, the fluid in the legs is not picked up efficiently and causes swelling.