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.