Europe thought that WW1 would be a repeat of Sedan[1], not Petersburg[2].
The generals of the Civil War studied Clausewitz and Napoleon, and the troops went to war with smooth-bore bronze cannon and Napoleonic fire drill. They were largely tempered in the brief, not-too-bloody, and glorious Mexican-American War. It took them a few years and tens of thousands of casualties to learn what havoc accurate, long-range rifles, even if muzzle-loading, could do.
Militaries are eternally building themselves to fight the last war. When they do learn from their experience, quite often the lessons learned are the wrong ones.