Theorem : If $x$ is algebraic over $\mathbb{Q} $, then $\mathbb{Q}[x]= \mathbb{Q}(x)$
My doubt : Here $\mathbb{Q}(x)$ is field and $\mathbb{Q}[x]$ is not field since $\frac{1}{x} \notin \mathbb{Q} $ but $\mathbb{Q}[x]$ is ring
we know that field $\neq$ ring
Then why $\mathbb{Q}[x]= \mathbb{Q}(x)?$