Both notations are usually admitted.
The notation $f(x) = \mathcal O(g(x))$ is quite convenient I find, since it allows you to manipulate equalities very easily. For instance, if you have
$f_1(x) = \mathcal O(g(x))$ and $f_2(x) = \mathcal O(g(x))$ you can these equalities up to get
$$
f_1(x) + f_2(x) = \mathcal O(g(x)) + \mathcal O(g(x)) = \mathcal O(g(x)).
$$
This is just one (extremely simple) example among so many.
However, the notation $f(x) \in \mathcal O(g(x))$ has the advantage that it reminds you that the function is in a certain class of functions, and that from $f_1(x) = \mathcal O(g(x))$ and $f_2(x) = \mathcal O(g(x))$ you cannot conclude that $f_1(x) = f_2(x)$.
Indeed, $f(x) = \mathcal O(g(x))$ means that $f$ is a function verifying $f(x) \leq M g(x)$ for a certain $M$ and for all $x$ large enough, but of course such a function is nowhere near unique.