One of the reasons for retaining fluid may be heart failure. The body produces a protein when the heart is not working well. This is BNP. This is from the Mt. Sinai website.
Brain natriuretic peptide test Information | Mount Sinai - New York.
If the levels are high or go up they frequently correlate with less than ideal heart function.
When my mitral insufficiency decompensated a number of years ago by BNP went up and I retained more fluid. Initially it is seen in the legs and ankles due to gravitational reasons. In severe cases fluid builds up in the lungs which adds to shortness of breath and the inability to lay flat due to increased fluid when not vertical,. The body holds onto sodium and the sodium holds onto water since the body attempts to maintain the appropriate sodium concentration. Diuretics help the kidneys dump sodium and the water associated with it.
So following the BNP is useful as a measure of heart function. Also a low sodium diet will help avoid water overload.
When I was an intern on a cardiology ward at the VA we use to have the patients leave over the weekends on passes if they were stable enough, They were told to avoid sodium. Invariably some would return in significant heart failure and needed large doses of diuretics to dry them out. When asked if they avoided sodium they would all say they did but then they would admit to eating pepperoni pizza. There are some other issues that could lead to accumulation of fluid such as very low plasma protein levels but by far the most common is cardiac dysfunction to some degree along with excessive sodium intake.
Vein issues as mentioned could be the cause of fluid in the lower legs but this should be more of a chronic issue and often is associated with significant varicosities. If one had a saphenous vein used for cardiac purposes the leg that it was harvested from might develop unilateral edema.