Is WW2 the only example of this that created the stereotype? Even in WW2 they were fully beaten so why are they called cowardly? The Germans surrendered in WW1 and Napoleons defeat was not really cowardly because his troops fought to the last man at Waterloo.
There's a few threads in the FAQ dealing with this, I'll try to summarize a comment posted by /u/smileyman in a previous thread.
You're correct in saying the French military track record is quite good, even in the world wars. Napolean was certainly a capable military leader; the French didn't fare much worse than the Americans in Indochina (Vietnam); and their problem in the opening stages of WWI was, if anything, the fact that they placed far too much value on attacking ("The French army, returning to its traditions, henceforth admits no law but the offensive... " -- from the 1913 Field Regulations, as quoted by Barbara Tuchman in The Guns of August). The stereotype appears to have stemmed from the Second World War and the tensions between the French and Anglo-Americans that followed it, culminating in France's exit from NATO in 1966.
They collapsed quickly in 1940, for a variety of reasons. They were pretty much trained and equipped to re-fight WWI at that point (just like pretty much everyone except Germany). When German armour outflanked them through the Ardennes forest, their massive and very expensive border fortifications were suddenly facing the wrong way. Their government and industry was also in chaos, meaning that even though they had excellent tanks and aircraft, there often either weren't enough of them, or they were in the wrong place at the wrong time.
Enter Charles de Gaulle. He was instrumental in making sure France came out of the war on the side of the victors, but he often grated on the English and Americans. He became President several years after the war, and oversaw the French withdrawal from NATO in 1966. The tensions and anti-French sentiment that led to and/or resulted from this, combined with the collapse of France in 1940 and the existence of the collaborationalist French Vichy government thereafter, is probably the root of the stereotype, though it's hard to say for certain.
Sources: Barbara Tuchman, The Guns of August Len Deighton, Blitzkrieg McEvedy, Colin, The Atlas of Recent History: Europe Since 1815
Please look at the FAQ which covers this topic broadly within the 20 year rule.