The simplest blowup morphism $\mathrm{Bl}_0(\mathbb{A}^2) \to \mathbb{A}^2$ (with center at a point) is not flat.
EDIT. Here is an example with affine morphism. Let $$ X = \{ x_1y_1 + x_2y_2 + x_3y_3 = 0 \} \subset \mathbb{A}^3_{x_1,x_2,x_3,x_4} \times \mathbb{A}^2_{y_1,y_2,y_3} $$ and let $f \colon X \to \mathbb{A}^2$ be the projection to the second factor.