I found the following result on the web:
Theorem. Let $f:X\rightarrow Y$ be a morphism of varieties, and assume that the dimension of all fibers $n=f^{-1}(P)$ is the same for all $P\in Y$. Then $\dim X=\dim Y+n$.
Question 1: Should I also ask that all the fibers are irreducible (to enable me to talk about its dimension)?
Then the proof goes by induction on $\dim Y$, with the case $\dim Y=0$ trivial, since $Y$ must be a point.
On the inductive step, we may assume $Y$ is affine. For a nonzero regular function $g\in \mathcal{O}_Y(Y)$, we have that $Z(g)=\{y\in Y:g(y)=0\}$ has pure codimension $1$, hence any of its irreducible components has codimension $1$. Now, putting $X'=f^{-1}(Y')$, where $Y'$ is some irreducible component of $Z(g)$, we have by inductive hypothesis that $\dim X=\dim X'+1=\dim Y'+n+1=\dim Y+n$.
My attempt to justify the above conclusion is to observe that $$X'=Z(g\circ f)=\{x\in X:g\circ f(x)=0\}.$$ So, if $g\circ f$ is nonzero, then it has codimension $1$ on $X$ and everything works fine. However, I cannot guarantee this (at least I don't see how), so:
Question 2: The hypothesis about the dimension of the fibers can be used to justify my attempt? If not, how the hypothesis should be used to finish the inductive proof?
Thank you very much for your attention.
Given a non-zero $g\in\mathcal{O}(Y)$, let $Z_1,\ldots,Z_k$ be the irreducible components of $Z(g)$. The first thing you need to observe is that each $f^{-1}(Z_i)$ is union of irreducible components of $V(g\circ f)$. This is becuase for any irreducible component $W$ of the latter, $f(W)$ is an irreducible subset of the former. Given $i$, choose an irreducible component $W_i$ of $f^{-1}(Z_i)$ (hence of $V(g\circ f)$). Notice that $f:W_i\rightarrow Z_i$ verifies the hypothesis with the same $n$ (independent of $i$!, and here is where the hypothesis is important) and then you can apply induction.
You will see this better if you consider the case $\dim Y=1$ in which case $V(g)=\{P_1,\ldots,P_k\}$ and $V(g\circ f)=f^{-1}(P_1)\cup\ldots\cup f^{-1}(P_k)$.