This is a question about a proof in Hartshorne, but let me try to formulate it without reference to Hartshorne.

Let $X$ be a noetherian scheme (which is also integral, separated and regular in codimension one, but I doubt these are important conditions). Let $x$ be a point in $X\times \mathbb A^1$ (fibered product) of codimension $1$. Let $\pi$ be the canonical projection $X\times \mathbb A^1 \to X$. Why does the point $\pi\left(x\right)\in X$ have codimension $\leq 1$ ?

This is tacitly used by Hartshorne in "Algebraic Geometry", proof of Proposition 6.6, Chapter II. (In Hartshorne's language, this is the claim that every point of $X\times \mathbb A^1 $ of codimension $1$ is either type 1 or type 2.)

I know that $\pi$ is surjective on the level of sets, but not sure whether this is enough. Maybe there is a nice definition of codimension that does not rely on irreducibility? (I feel that such a definition would make working with codimension easier.)

Generally, what kind of maps in algebraic geometry are known to not increase codimension of points? Is there some type of scheme maps (proper, finite, closed, etc.) that always has this property?

[Full disclosure: This is related to my homework (exercise 6.1 in Chapter II), where I have to do something similar for $X\times \mathbb P^1$; but I can reduce this to the $\mathbb A^1$ case and take the proof of Proposition 6.6 for granted. So you are not helping me cheat; you are preventing me from doing so.]