Consider a commutative local ring R, say a valuation domain, with maximal ideal M. Consider the fiber product $R \times_M R$ (I wrote M instead of R/M), coming from the pullback in commutative rings $R\rightarrow R/M$. Then the corresponding prime spectra of this fibered product (in rings) is actually a form of gluing of the same same (affine) scheme Spec R along the closed point M. So this is the case where this happens.
Consider a commutative local ring R, say a valuation domain, with maximal ideal M. Consider the fiber product $R \times_M R$ (I wrote M instead of R/M), coming from the pullback in commutative rings. Then the corresponding prime spectra of this fibered product (in rings) is actually a form of gluing of the same same (affine) scheme Spec R along the closed point M. So this is the case where this happens.