If the L/D ratio was less when any flap extension, why could a take-off flaps shorten take off distance (for some aircraft such as the C172)?
Well I don't know how much flying experience you have Issac, but this question seems perfectly reasonable to me. In fact I would say that it shows that you are devoting some serious thought to the problems of flight.
An efficient L/D ratio is important
in flight if one is considering climb or descent gradient or cruise performance.
For take-off and landing, one is more concerned with the time and distance required either to get airborne or to come to a halt so the airborne performance is not so much of an issue.
As others have stated, especially
baikonur whose explanation I like, the use of flaps lowers the stall speed and therefore enables the aircraft to lift off at a lower speed, with all the benefits that accrue (mainly the shorter ground run). The effect of the flaps on the subsequent climb may not be as beneficial but that comes under the heading of 'compromise', of which aviation is full!
Keep thinking about these things and keep asking questions. That is a good way to learn!