Lent is defined as forty days and, in the Western reckoning, does not contain forty consecutive ones. The arithmetic is the interesting part.
From Ash Wednesday to the day before Easter is forty-six days. Sundays are excluded from the fast because every Sunday is a commemoration of the resurrection and a fast day cannot fall on one. Forty-six less six Sundays gives forty. That is why the season begins on a Wednesday: counting back forty fast days from Easter lands there.
This arrangement is later than the season. The earliest evidence, in the fourth century, has Lent beginning on a Sunday, six weeks before Easter, giving thirty-six fast days, a tithe of the year, as some patristic writers noted approvingly. The four extra days were added at Rome, probably in the seventh century, to reach the symbolic forty.
The Eastern churches count differently and arrive at a different structure. Great Lent begins on Clean Monday, seven weeks before Pascha, and ends on the Friday before Lazarus Saturday; Holy Week is reckoned separately rather than as the end of Lent. Saturdays as well as Sundays are exempt from the strict fast.
The number itself is scriptural rather than arbitrary: forty days of Jesus in the wilderness, forty years in the desert, forty days of rain, forty days of Moses on the mountain. In biblical usage forty frequently means a long formative period rather than a count.
What was fasted from has varied enormously. The early practice was severe, one meal a day, no meat, no dairy, no eggs, no wine, and Western requirements were relaxed repeatedly from the medieval period onward.