The CSA army in Northern Va. did not win every battle up until Jackson was killed. McCellan may have left the Peninsula but, Lee was beaten badly in the first and last battle of the "Seven Days." Some of Jackson's actions/inactions contributed to both defeats.
The North also had railroads of the same gauge, more bodies to draw on, a better economy, and, what may be most important, a central government. The South, to its determent, was a bunch of governments constitutionally superior to Richmond/Montgomery, which severely limited the power of the so-called President and therefore could not unify with regard to a single, cohesive war plan. The power of the individual CSA states precluded moving troops to where they were needed and could be best used. It prohibited nationalizing among other problems for President Davis. He was not a consensus maker, he was a stubborn individual and therefore not the man for the job. A confederation requires consensus to work.
The Confederacy usually had the advantage of interior lines and could not develop a consensus as to how to exploit. Lee's move into Pennsylvania gave the Union interior lines which they exploited to Lee's discomfort. Lee, as much as I admire and even revere him, was the perfect leader for a defensive war. Offensively? Not so good. Then, once Grant was put into control the Confederacy had no chance. A war of attrition was not something they could engage in. Grant basically had unlimited resources which he could only lose if the public lost interest in the outcome of the War. Neither France nor Great Britain ever seriously considered coming to the aid of the Confederacy. Ever! Especially when the Czar sailed his fleet into British and French ports as a show of support for the Union.
After First Manassas/Bull Run it was simply a matter of time until the South was whipped. Too many negatives. No central government. Little industrial power. Very limited foreign interest/support.
Lack of manpower resources, which they cut down further by illogically refusing to use "blacks" in their army until way too late. Gorgas? Brilliant with severely limited resources. Lee? Brilliant defensively. Hood? An idiot! Bragg? Another Hood. Jos. Johnson? More than adequate but, shy when using his assets. I could go on. Forrest? A minor actor, a thorn in the side of one Northern army but, little else. The South was blessed with a ton of good wing commanders but only two, possibly three leaders of armies.
The North, although it took a while to find them, was blessed with some outstanding Army commanders. Meade gets little credit. He deserves more. Sherman? He knew the objective was not the Confederate Armies. He went after the will to fight. A plan proven to be correct. Grant had a wide and cohesive plan and, with the right lieutenants, was able to wage "total war" across all fronts. Something the South was never ever able to come close to nor wished to.
It was a war the rich in South Carolina could not conceive of when they kicked it off. They sorely underestimated the fighting qualities of men from the north, the Norths' ability to mobilize and sustain a war machine and, while valorious, the few fighting men of the South could not overcome a lack of support from the inept central government, a poor economy (cotton proved to be less important as the war dragged on, something inconceivable to the Southern planters), lack of equipment, horses, succor, etc. It was a war the South was destined to lose with the adoption of a confederacy style of government.
The Confederacy's constitution, with its decentralized government, precluded any hope of victory once the North decided to win and mobilized all of their assets. The result was, in hindsight of course, a foregone conclusion. The North selected "total war." The South couldn't and wouldn't fight a "total war." Such a destructive war went against years of "genteel" thinking. Chevaliers simply did not wage war in that manner. Laying waste to entire valleys, burning crops and leveling cities was anathema to Southern (read, patrician) sensibilities. Many in poor old Atlanta still cannot come to grips with the destruction of their city a hundred plus years ago.
The rich landholders ran, a handful even fought, the various state governments, controlled the forces and simply could not surrender their prerogatives for the good of the nascent country.
Just the two designations, Confederate States v. United States, are indicative of why the Confederacy was doomed to failure from the git go. The strongly centralized Union was able to harness all their assets, the loosely controlled Confederacy could not even get a consensus as who commanded the troops, Governors or the President and his Generals.