Why does right-sided heart failure causes swollen feet and ankles?

Pump failure. The right side of your heart accepts blood returning from the extremities. If it can't keep up, blood starts to back up in the extremities and causes swelling. Think of a basement pump. If its not powerful enough to keep up with the water seeping in, the basement will flood.
Pump isn't working. If the pump is having a hard time getting the blood into the heart it will end up staying in the dependent areas (ie legs) so one will get swollen legs and ankles.