I'll take the question to mean "could any contemporary Allied commander have taken over from Gamelin in 1940 and won the Battle Of France?" Anything else is too broad or drifts into fantasy. The question is still very broad, so I'll focus on one aspect: the mechanized maneuver warfare which was the real German "secret weapon".
Could any contemporary Allied commander have taken over from Gamelin in 1940 and adapted to the mechanized maneuver warfare being used by the Germans?
No, Because WWII Was Different Than All Before It.
My question is pretty straightforward! Was the battle against France won because the Germans were so well organized and used superior tactics that France didn't really stand a chance (unless they would've had a brilliant commander like Napoleon or Hannibal of course) or because the French were so poorly prepared and had a weak leadership?
This comment by the OP (since edited, still useful) is illustrative, particularly the part about having Napoleon or Hannibal in charge. Commanding an army in 1940 was not like commanding one in 1918 which was not like commanding one in the Napoleonic era which was certainly not like being a commander in Hannibal's time. While the very basics remain the same, 1940s warfare was conducted at a pace and scale that would have made Napoleon give up and crawl back into his tent. In fact, several actual early WWII commanders did just that! Hannibal, who never commanded more than 50,000 men, would have no grasp of a modern military staff nor communications; he might have made an excellent company or even division commander with training. The Allied armies in the Battle of France numbered over 3 million and spanned hundreds of miles.
Prior to WWII, warfare was still centered around the Set Piece or Pitched Battle. This is a battle conducted at a time and place by two well defined units with well defined lines and commanders have a pretty clear strategic understanding of the entire battlefield. Emphasis on well defined. While not always planned, sometimes it comes out of a meeting engagement such as the Battle of Gettysburg, they have a fairly clear and limited scope. Everything from Cannae to Waterloo to the Somme has this basic shape. Napoleon, after some technological catch up, would have done well in the trenches of WWI.
The Spring Offensive at the very end of WWI introduced modern large-scale maneuver warfare. While maneuver and deception has always featured prominently in warfare, primarily flanking maneuvers, it was always on a tactical level of individual battles and carefully controlled. Now this idea is applied to all levels of the battle, from individual small unit tactics to large scale maneuvers.
Mechanized Maneuver Warfare
Rather than destroying the enemy in a series of pitched battles, maneuver warfare seeks to keep the enemy always off balance and confused. Rather than attacking the enemy's defenses, it circumvents them and instead aims at logistical and command structures to remove the enemy's ability to fight in a coordinated fashion. The divided defenders can then be mopped up by concentrated attacks which achieve surprise and local superiority despite having overall inferior numbers.
This cannot be achieved overnight. It requires sweeping reforms from top to bottom: from top commanders to sergeants to individual soldier's training and equipment. It requires extensive use of mobile radios (still not widely available in 1940) and new communication and command techniques. It requires having a significant portion of your army mechanized and concentrated to act as a fast reaction force to both exploit opportunities and plug holes.
The Germans Had Experience, The Allies Did Not.
While most major militaries entering WWII had their own theories of large scale maneuver warfare, Soviet Deep Battle or the British Experimental Mechanized Force, they had little operational experience and understanding of how it would work in practice. A new Allied commander showing up in 1940 or even 1939 would have scant time to adapt their existing army of 3 million in the field to conduct maneuver warfare. This was an army mostly prepared and trained to fight WWI over again. They didn't have the equipment, the men and commanders did not have the training, nor even the schools necessary to conduct the training, nor the designs and factories to produce the equipment to conduct mechanized maneuver warfare.
In contrast, the Wehrmacht learned their lesson from WWI and had rebuilt their army, commanders, soldiers, and equipment around the concept of maneuver warfare. They gained experience from the Spanish Civil War, and unlike the Soviets, made the correct conclusions giving them several years to prepare.
The Occupation of Austria and Occupation of Czechoslovakia, while they involved no fighting, gave the German army valuable, practical information about large scale deployment and movement of their armies. Mundane but very important issues of maintenance, supply, and communication could be worked out in reality, not just on an exercise. How do you deal with mechanical failures? Traffic jams? How do you get food and fuel and ammo to an army constantly on the move? How well do radios actually work in the field? How well do air and ground forces coordinate?
By the time of the Invasion of Poland, the German army had years to prepare and two large scale real maneuvers to work things out. Even though Poland was, in some ways, a walk over it revealed more problems.
Fortunately, the Allies gave Germany six months to work them all out, recover, and reorganize. The German army that invaded France was now one well tested in the field, and perhaps the only major army in the world at the time with extensive experience in mechanized maneuver warfare. While the Allies had none.
The Saar Offensive, The Best Opportunity To Change History.
To a WWI commander sitting behind your defenses waiting for the enemy to attack is good policy. To a WWI commander, the well-prepared defender always has the advantage: chop up the enemy as they try to bludgeon their way through your lines.
To a modern commander, an army with superior numbers sitting for months behind their defenses waiting to be attacked is madness. It gives the attacker time to prepare logistically, build roads, build rail lines, build up supplies, repair, refit, and reorganize. It gives them time to gather intelligence, probe defenses, and form an accurate map of the enemy's unchanging positions. The attacker can then attack at the time and place of their own choosing.
This is exactly what happened after the invasion of Poland: the Sitzkrieg or Phoney War. Six months of the Allies doing almost nothing while the Germans recovered and prepared. But it didn't have to be that way.
The one place a more vigorous Allied commander could have made a difference was in the Saar Offensive. When Germany invaded Poland, it committed the overwhelming bulk of its forces; its western border with France was very thinly defended. It was another bluff that paid off.
A vigorous Allied offensive in the West in September 1939 could have called that bluff and left Germany in a very awkward position suddenly fighting a two-front war. They would have had to scale back or even halt their invasion of Poland and strip units to defend against and repel a French attack. The French could have pierced the Siegfried line before Germany could bring in sufficient reinforcements, they'd be fighting on German soil behind German static defenses, exactly what they wanted to do.
Meanwhile, the Poles were no slouches and could have held back a diminished German army. In reality their fate was sealed by a Soviet offensive from the east, the Soviets invaded seeing easy pickings and gaining a buffer zone against continued German expansion; even then the Soviets waited until mid-September when they had formally ended their undeclared war with Japan and felt their eastern front was secured.
If the Saar Offensive actually happened, and happened quickly enough, the Soviets may have hesitated further in invading Poland waiting to see how Germany would fare. A Germany distracted by extensive war in the West was not a great threat to the Soviets, and without the German army taking apart the Poles the Soviets would actually have to fight in Poland.
Italy would be unlikely to intervene, like the Soviets in Poland they only declared war on France after it was clear the battle had been won.
Germany would now find itself in serious trouble with its military stretched thin, its aura of invincibility punctured, its fair-weather allies hesitating, and the long-term deficiencies of its military in conducting a prolonged war made clear. There would have been no invasion of Norway, Denmark, nor the Low Countries meaning no forward bases for the U-Boat campaign nor bombing Britain.
While it's entirely possible the German army would have still defeated the invading Allied army, it would have to do so on its own soil rather than deep in French territory. It would then have to return to finishing off Poland before striking at France. Rather than victory in eight weeks, this might have turned into the longer, slower paced battle the Allies prepared for.