Corn comes out whole in our poop because corn is not that easy for our stomach to digest like other foods.
The reason corn is hard for our stomach to digest is because corn has an outer shell of a compound called cellulose and our bodies and stomach doesn't contain the needed enzymes that specifically break down cellulose.
So although our stomachs cannot break down and digest the cellulose that corn contains your body can break down the food components that are inside corn.
So that's why you see whole corn pieces in your poop due to the body having a hard time digesting the cellulose of the corn.