What can cause persistent fluid in the lungs and swollen ankles, despite taking diuretics continuously?

Several possibilitie. Pneumonia, adult respiratory distress syndrome, advanced malnutrition, congestive heart failure, hepatorenal syndrome, uremia. The lack of response to diuretics implies that either the condition isn't responsive to diuresis or the dose needs to be adjusted. The condition appears to be complicated and should be further evaluated with consultants as needed.
Congestive failure. If your heart is struggling to efficiently pump blood, fluid can back up in lungs and legs. Stay in close contact with your doc, keep a daily record of your weight, stay on your medications. Go in to see your doc if your weight jumps up or you get short of breath.
Inadequate dose. If you are taking the diuretic for heart failure and you have persistent edema and fluid in lungs your dose of diuretics is inadequate either dose is too low, medication is not being absorbed in gut, or medication is not being transported to kidney. Will need an increased dose of diuretic, a different diuretic or an additional diuretic.
Congestive heart . Failure or kidney problems are. 2 thoughts but there could be others. Recommend you discuss with your physician.