There is an adjunction between locally ringed spaces and rings given by $R\mapsto \text{Spec}(R)$ and $X\mapsto \Gamma(X, \mathcal O_X)$.
Is that adjunction idempotent?
Roughly equivalent: Is it true that the canonical morphism $R\to \Gamma(\text{Spec}_R, \mathcal O_{\text{Spec}(R)})$ is always an isomorphism and that the canonical morphism $X\to \text{Spec}(\Gamma(X, \mathcal O_X))$ is an isomorphism if and only if $X$ is an affine scheme?
Yes.
More categorically, we know that the category of affine schemes is antiequivalent to the category of rings (see here) and this equivalence is given by $\text{Spec}$ and $\Gamma$. Idempotent adjunctions always give rise to an equivalence of categories between the categories of fixed points, and we see that behavior here.
I hope this helps ^_^