Trench warfare was used in the US Civil War. The Overland Campaign saw extensive use of trenches. The Crimean War also saw the use of trench warfare. Digging trenches was a common practice of European Warfare pre-WW1. The siege of Fortresses/Cities often involved digging long siege lines around cities.
A better question might be, why was trench warfare used so extensively in WW1? What made trench warfare in WW1 different?