Early modern armies knew about trenches and fortifications and used them often, but these wars didn’t turn into WWI style trench wars because trenching takes a lot of labor and locks in positions that the enemy can just go around. There were fewer scenarios where you could know that the enemy would attack you in a particular position, so building a trench would just get you avoided. Part of warfare is maneuvering around and trying to start a battle when you have the advantage, but if you want to engage the enemy, they wouldn’t fight you if you are entrenched in too strong a position, unless they had to.