- implies 2. for any scheme.

*Proof:* We have $\dim X = \sup_{x \in X}\dim \mathcal O_{X,x}$ (Lemma 5.7 in Görtz/Wedhorn).

Now let $\dim \mathcal O_{X,x}$ be the same for all $X$ and $Y \subset X$ some irreducible component. There exists some $x \in Y$, which is not contained in any other irreducible component and then we have $\mathcal O_{Y,x} = \mathcal O_{X,x}$, hence $\dim Y \geq \dim \mathcal O_{Y,x} = \dim \mathcal O_{X,x} = \dim X \geq \dim Y$, which shows the result.

In general, 2. does not imply 1. For a counter example, it suffices to give an integral domain, where the maximal ideals have different heights.

Let $R=k[x,y], \mathfrak m=(x,y), \mathfrak p = (x-1)$. Let $A=S^{-1}R$ for $S=R \setminus (\mathfrak m \cup \mathfrak p)$. The maximal ideals of $A$ are $\mathfrak m$ and $\mathfrak p$, of height $2$ and $1$ respectively.

If we restrict to the case, where $X$ is of finite type over a field, then the equivalence is true. The reason is the fundamental formula:

$$\dim A = \operatorname{trdeg}_k K,$$
where $A$ is a domain of finite type over $k$ and $K$ the fraction field of $A$.
Geometrically, this means we can compute the dimension of the local ring $\mathcal O_{X,x}$ by looking at the function fields of the irreducible components, that contain $x$. Hence the dimension depends only on the irreducible components, not on $x$ itself.

You can look this up in Görtz/Wedhorn, Theorem 5.22 and Corollary 5.23. The formula above is covered by any textbook on commutative algebra/algebraic geometry, which mentions the concept of dimension.