There are many reasons that it took the Union 4 years to defeat the Confederacy, but superior Confederate generalship is not one of those reasons.
Union generals Burnside, Butler, Hooker, Pleasanton, Pope, and Sigel are generally considered to be some of the worst generals of the war, but outside of Virginia they repeatedly beat the Confederates – Sigel was competent at Pea Ridge, Burnside shut down most of the North Carolina coast and later beat Longstreet, Hooker performed well at Chattanooga and in the Atlanta Campaign, Pleasanton drove the Confederates from Missouri, Pope cleared the Mississippi south to Memphis, and Butler waltzed into New Orleans.
Robert E Lee was arguably the Confederacy's best, yet he never won a campaign outside of Virginia and he was beaten by Meade, who is generally considered a second-string Union general, and by Rosecrans, who is often considered one of the Union's worst generals. Jackson varied in quality - his performance in the Seven Days Battles was poor. At Brandy Station, Stuart was surprised by Pleasanton, who as noted is often considered one of the Union's worst generals. At Knoxbville, Longstreet was beaten by Burnside, who is also considered one of the Union's worst generals.
Joe Johnston was probably the best the Confederacy had in the west, and he wasn’t good enough. AS Johnston was out of his depth - he did not just fail as an army commander, he failed to be an army commander. Floyd and Pillow were cowards. Sibley led his forces to disaster in Arizona. Van Dorn did the same in Arkansas. Price did the same in Kansas, losing to Pleasanton, who is often considered one of the Union's worst generals. Polk was an incompetent backstabber; the Union did a service for the Confederacy when they killed Polk with artillery fire. Hood was a backstabbing subordinate and a total disaster in command. Bragg was one of the few Confederate generals to win battles, but he had no idea what to do with a victory and his abrasive nature helped erode what little cohesion his Confederate army had. During Early's one solo command in the Shenandoah Valley in 1864 he was unable to defeat Franz Sigel, who as you may guess was also considered one of the Union's worst generals, then fatally delayed at the Battle of Monocacy, by Lew Wallace, a man far more noted for his literary accomplishments than his military skill.
Real Confederate advantages were a large territory, good defensive ground, interior lines, fighting on home ground, and the force multiplier of being on the defensive. Confederate leaders frequently threw these advantages away to invade Union territory. Rather than using their real advantages, the Confederacy clung to the myths of having better soldiers and better generals, which resulted in failure from Gettysburg to Glorietta Pass.