Sending troops into enemy territory to fight is NOT “taking over”. It is fighting, trying to gain an advantage militarily to reach whatever ends are desired. Just because they did indeed try to infiltrate neighboring enemy territory does not mean it was the intention to confiscate that territory to annex to their country. Else the US would’ve wanted fully to wrest Canada from the UK, or the US would’ve intended to annex France or Germany from them in either war.
BTW, MD was a “Union” state by force. MD was 1 of the few truly divided in this war and it was a slave state, with MANY southern sympathizes/self-identified. Don’t be misleading. Natives mobbed them and it was hardly any kind of “invasion”.
In fact, the Confederacy laid claim and attempted to "take over" Union states and territories of Maryland, Kentucky, Missouri, Oklahoma, New Mexico and Arizona, as well as Union sympathizing areas of secessionist dominated states in Western Virginia, Eastern Tennessee, Western North Carolina and parts of Arkansas.
Further, RE Lee's 1863 campaign into Pennsylvania was intended to not only decisively defeat the Union army, but also to establish a permanent base across the rail line junctions in the state capital of Harrisburg.
Such a base could threaten all major northern and western cities as well as provide supplies for the Confederacy.
If successful, why would they ever give that up?
So the Confederacy was as aggressive towards the Union as it could be -- often failed, but not for lack of trying.