Howdy Susan,
I think it comes down to this:
Dupont was given what was thought by Napoleon an easy task as N dismissed the quality of the troops he sent Dupont as well as the effort a Spanish Army would put forth. Dupont's troops were very ill-disciplined and further incensed the Spanish populace to greater resistance as well as the army. His supply line was not secure and a general sent down from Madrid got himself and staff captured and boiled alive. The Spanish Army fell on his exposed flank and got behind him. The heat of the day, the hodge-podge of inexperienced French units, the wavering Swiss regiments (formerly in the pay of Spain), and even a last desperate charge by the Sailors of the Guard were to no avail. What choice did he have, but surrender? Unfortunately, he also included Vedel's division, which could have escaped. Unfortunately, it was the first defeat of a French Army and Napoleon would not own up to his part in it -- a scapegoat was necessary and Dupont was it. The loss of a guard unit also had to gall Napoleon -- especially the highly regarded Sailors.
Happy Holidays! Jerry