I have seen people keeping numerous fasts in an year. Where does the idea of fasting originate, and what is the reason behind keeping a fast?
One reason for fasting is to atone for one's papa (usually translated as sin).
For example, in Mahabharata Santi Parva, section 36, Vyasa said,
By penances, religious rites, and gifts, O Bharata, a man may wash off his sins if he does not commit them again. By subsisting upon only one meal a day, that procured by mendicancy, by doing all his acts himself (without relying on the aid of a servant)....by becoming a brahmacharin and always ready for exertion, by casting off all malice, by sleeping on bare ground, by publishing his offence to the world, by doing all this for full 12 years, a person can cleanse himself from the sin of having slain a Brahmana. .....By living upon the scantiest meal every day for a space of six years, a person may be cleansed of that sin . By observing a harder vow with regard to food one may be cleansed in three years . By living upon one meal a month, one may be cleansed in course of only a year. By observing again an absolute fast, one may be cleansed within a very short time.
REF: Ganguli's translation of Mahabharata, Santi Parva, Section 36
 Ganguli remarks in a foot note that the rule laid down is that he should eat in the morning for the first three days, in the evening for the second three days, eat nothing but what is got without soliciting for the next three days and fast altogether for the three days that follow.
 The harder rule referred to is eating in the morning for seven days; in the evening for the next seven days; eating what is got without soliciting for the next seven days; and fasting altogether for the next seven days.
Fasting is just one kind of a vrat. Vrat generally means observing with determination (vow) the rules of the scriptures:
śastrodito hi niyamo vrataṃ tacca tapo matam [Agni Puran - 175.2]
Certainly, rules ordained by the scriptures are called vrata. That too is also said as tapa.
Depending upon what vow is observed it can be Satyavrat (vow to be truthful), Pativrat (vow to be loyal to husband, hence we call pativrata stri ), Upavasvrat ( vow to abstain from regular activities like like eating, sleeping, mating, etc.). So there are many kinds of such vratas given by different kinds of puranas for different purposes. Some are observed on particular days, or for particular number of days and some are observed throughout the life.
In a vrata certain difficult tasks like fasting are observed because the samtapa (pain) of such tasks act as tapa (heat) to burn away sins. And pleased by the vrata the gods and God give enjoyment, liberation, etc.
vrataṃ hi kartusantāpāttapa ityabhidhiyate [AP - 175.3]
The person observing vrat has to under go physical pain, hence vrat is also known as tapa.
te syurdevādayaḥ pritā bhuktimuktipradāyakāḥ [AP - 175.5]
The vrata pleasing gods and God awards enjoyment and liberation.
Now different puranas (padma puran, vishunu puran, etc.) mention different kinds of vratas with specific rules to observe on specific days for specific deities. So people keep numerous fasts in a year. As most of the vratas include fasting, people abstain from eating completely or eat only fruits as may be permitted by the vrat.
By doing Vrat, evil/bad qualities get destroyed and good qualities emerge. By performing Vrat one gets eligibility for Diksha/Initiation. After initiation, one will grow and progress, consequently s/he will find good faith towards Satya and ultimately such faith leads to the Satya.
According to Shukla Yajurveda, Adhyaya 9:
व्रतेन प्राप्यते दीक्षा दक्षिणा दीक्षाप्राप्यते।
तया च प्राप्यते श्रद्धा श्रद्धया सत्यमाप्यते॥ ३० ॥
30 He gains by vow of fasting Consecration, by Consecration gains the priestly guerdon. He gains by priestly guerdon faith: by faith comes knowledge of the truth.
Ekadasi, the mother of all Vrattams comes in the next day or two depending on where we live. Please check your Panchangam or Calendar for Thithi as it is based on sun rise. Sri Periyava’s strong message on observing this Vrattam is listed in the link below. The goal is to restrain ourselves from worldly activities as much as we can and spend time in Iswara Dhyanam, Purana Shravanam, and Bhagawan Nama Japam. Here is a summary of the levels of fasting prescribed by Sri Periyava. Let’s start at level 4 and with Periyava’s grace we will progress over a period of time. All we need to do is put in our sincere effort and Periyava will show us the way. Bare minimum, ‘Avoid Rice’ on this day and be in Periyava Smaranam. If possible, have an early dinner before sunset on Dasami (the day before Ekadasi) as Sastras prescribes that way. Spread this message to like-minded people as well. Ram Ram. 1. Nirjalam – Without water, very noble. 2. Sathvik Liquids – Water, Milk, Porridge 3. Fruits and Sathvik Liquids 4. Light Tiffin, Fruits – Upma/Idly/Dosa/Chapatti/Poori for one session (without any Patthu) and fruits or Sathvik liquids for another session. Consume this food without any salt. Please ‘AVOID’ taking rice on this day as Sri Periyava has warned about ‘No atonement’ if rice is consumed on this day. It is equivalent to consuming dog’s excretion in every handful we take.
Exemptions – People who are sick, weak, elderly can consume rice without Kanji water without salt, tamarind, and spice. People are who are below 8 and above 80 are exempted though they can also fast if they can. North Indian’s especially Bengali’s, Maharashtrian’s observe this fast Nirjalam (No Water) including infants and toddlers. Sathvik Liquids – Water, Milk, Buttermilk (no salt), Wheat Porridge (no salt). Coffee, Tea, Choco drinks, cool drinks, alcohol, are NOT ‘Sathvik’ Liquids. Let’s ensure whatever we consume does not contain ‘Gelatin’ as it will be terrible to have it on this day or rather any day.
Ekadasi Timings – Fasting is observed based on the existence of Ekadasi Thithi at the time of sunrise. Ekadasi may exist only for a partial day but if the Thithi on sunrise is Ekadasi consider fasting on that day. Check http://www.mypanchang.com/ for details on sunrise and thithi or your local calendars.
Breaking Fast on Dwadasi Morning – Check the Panchagam when the Dwadasi Thithi ends the next morning and do Paaranai (have full meal) before that time. If it is too early and food cannot be prepared offer ‘Thulasi’ Theertham or Milk to Bhagawan and break the fast by consuming it. Agathikeerai, Nellikai Pachadi (Gooseberry/Amla), Sundakaai are items included in Dwadasi menu to bring the body back to equilibrium after the fasting day. We all have a duty to feed Gho Matha every day but it is very auspicious and parama punniyam to feed Gho Matha with Agathikeerai on Dwadasi. Source and Original Posting from Deivathin Kural on Ekadasi – Click Here
Why fasting? Spiritual and Scientific rationale behind fasting – Please read the following chapters from Deivathin Kural: Click Here-1, Here-2