Why am I retaining water on my legs, ankles and feet, even if I have not eating for the day and some times I get swelling during the night?

Many reasons. Any chance your pregnant? Do you have varicose veins? Hypertension? And heart problems? Do you take any medications? Do you work? If you do do you stand a lot for work? There are conditins like lymphedema which is purely a leg swelling issue with no relationship to other comorbidities..
Many possibilities. Include circulation problems like heart failure, kidney problems, liver disease, low protein levels, obesity, varicose veins, low thyroid, etc. It is unusual for swelling to get worse overnight if you're lying flat. See a doctor to get evaluated for the cause.