Example (bijective morphism between affine algebraic sets)
Take $X = \mathbb{A}^1$, $Y = Z(x^3 - y^2)\subseteq \mathbb{A}^2$ and $$ \begin{align*} f: X &\to Y \\ t &\mapsto (t^2, t^3). \end{align*} $$ It is a morphism with an inverse $$ \begin{align*} f\inv: Y &\to X \\ (x,y) &\mapsto \begin{cases} 0, &(x,y) = (0,0) \\ y/x, &\text{otherwise} \end{cases} \end{align*} $$ but this is not a morphism.