Lee's armies invading Union states of Maryland (1862) and Pennsylvania (1863) took what they needed, because that's what Lee ordered them to do.
Other Confederate forces under different leaders took a different approach, including those invading Union states of Pennsylvania (1864), Ohio, Indiana, Kentucky, Missouri, and Kansas, to mention some.
Lonesome in Massachusetts: "The Confederate armies avoided contact with the Union forces as much as possible after Gettysburg, they were trying to wear down resolve in the North."
Here is my most comprehensive listing, so far, of Confederate invasions of Union states and territories.
Please note that not all came before Lee's Battle of Gettysburg.
All left trails of pillaging, some of burnings and a few even of kidnapping and murder.
I think your view that the war was only about slavery is as incorrect as the war had nothing to do with slavery. Virginia voted against secession in April 1861 and did not seceded until Lincoln called up troops for an invasion of the South.
My great-grandfather (4 of my great-grandfathers served in the Confederate army) served as a private in the 10th Virginia and was not a slave-owner, 95% of the population of Virginia were not slave-owners. Yet after the war he apparently raised two black teenagers for they are listed as part of his household in the 1870 census.
Union troops invoked total war against the citizens of Virginia— they burned farms, killed livestock, and destroyed mills. Sheridan’s destruction of the Shenandoah Valley and “The Burning” conducted in Fauquier, Prince William, Loudoun, etc. are well documented.