In general, if you have to go, you’re allowed to poop in the woods. It’s really just a matter of how you do it. Typically parks want you to stay 40 steps away from water, trails, and campsites.
Whether it’s to maintain nature’s integrity or protect water sources, regulations differ from place to place. Sometimes parks will require you to pack out all of your waist, including feces.
Most park websites will specify if you need to dig a cat hole and bury poop, or take it with you. Always check before heading out in order to adjust accordingly.