Why didn't the US civil war get as bogged down and stalemated as WW1? Was it for technological reasons, such as how good the rifles were or how well armed people were? Or due to the much bigger armies? Or that there was always a flank to turn in the US civil war? Or something else i'm not thinking of?
simple answer is -- a combination of technology, geography, and European military doctrine. Generally what you said.
At the outbreak of WWI, European commanders still engaged in battles characterized by large units of soldiers directly engaging each other. However, new advances in weaponry made these tactics impractical and costly. Massed defensive indirect fire of artillery positioned well behind the front line, combined with fire from entrenched machineguns, and infantry rifles which could produce a high volume of accurate fire, meant direct advances by large attacking units were likely to receive enormous casualties before they even reached a position to engage their enemy with return fire.
Also, the Western Front was a relatively crowded geographic area, especially towards the end of the war when literally millions of troops were concentrated on either side of the front. As you point out, there wasn't much flank and so progress generally meant having enormous numerical superiority and a willingness to sacrifice a great number of lives in actions that were generally a direct and open advance.
Aerial reconnaissance also equipped each side with greatly magnified intelligence capabilities, and so surprise maneuver to achieve a strategic advantage was much more difficult than it was during the Civil War, or the Crimean War.
Still, the Civil War was a bit of a preview of what was to come in WWI. Trench warfare on a large scale did occur in places like Petersburg and Vicksburg. Defensive fire from cover by rifled arms was shown to be an enormous tactical advantage. And the concept of 'total war', used by Grant, Sherman, Sheridan and a few others, was certainly what distinctly characterized WWI versus prior European wars.
Technology, basically.
The advantage of trenches is that, for the defensive side, you see him before he sees you. That's a reasonably advantageous position to be in when you've got a musket rifle, but when you've got a machine gun and snipers, it's even more stacked in your favour.
During the US Civil War, trenches were successful but ultimately the superior force could overcome them through sheer force of numbers and good planning. In the First World War, the odds were so stacked towards those in the trenches that you could send any number of infantry to attack a trench and they'd all be summarily picked off.
So it won't surprise you to learn that many commanders on both sides chose to do exactly that.