$\newcommand{\cA}{\mathcal{A}}\newcommand{\Ext}{\mathrm{Ext}}\newcommand{\Hom}{\mathrm{Hom}}$Let $\cA$ be an abelian category; then, $\Ext_\cA^i(A,B)$ is literally $\Hom_{D(\cA)}(A, B[i])$, where $B[i]$ denotes the shift. A good way of thinking about this is as the cohomology of the derived Hom $\mathrm{R}\Hom_{D(\cA)}(A, B)$. In the case $i=1$, an element of $\Ext^1_\cA(A,B)$ is then literally a map $A\to B[1]$. The kernel $K$ of this map (in the derived category) defines a distinguished triangle $K\to A\to B[1]$. Since we're working in a derived --- in particular, triangulated --- category, we can rotate this further back to a distinguished triangle $B\to K\to A$. This is precisely the data of an extension.
Choosing $\cA$ correctly specializes to most of the examples you wrote in your question. For instance:
- If $\cA = \mathrm{Mod}_R$ for some commutative ring $R$, then $\Ext_\cA$ is literally the Ext-group that you wrote down.
- If $G$ is a group, then $\cA$ can be the category of representations of $G$ on $\mathbf{Z}$-modules (i.e., abelian groups). Recall that a representation is just a module over a group ring. In this case, the group cohomology $\mathrm{H}^i(G; M)$ is $\Ext^i_{\mathbf{Z}[G]}(\mathbf{Z}, M)$: you can think of this as derived Homs from the unit object $\mathbf{Z}$ into your $G$-representation. I'll address central extensions below.
- If $\cA$ is the category of modules over the universal enveloping algebra $U(\mathfrak{g})$ of a Lie algebra $\mathfrak{g}$ over $k$, then $\mathrm{H}^i(\mathfrak{g}; M) = \Ext^i_{U(\mathfrak{g})}(k, M)$. Again, these are derived Homs from the unit object $k$ into your $\mathfrak{g}$-module.
- If $A$ is a $k$-algebra, and $\cA$ is the category of $A$-$A$-bimodules, then Hochschild cohomology is $\Ext^i_{D(\cA)}(A, M)$. Again, these are homs from the unit object $A$ into your $A$-$A$-bimodule.
Andre-Quillen cohomology fits into this formalism as well, but this time you're not taking derived Homs into an object in the heart of your derived category (i.e., a usual module). Let $A$ be a commutative ring, and $B$ be an $A$-algebra. If $M$ is a $B$-module, then the Andre-Quillen cohomology is (by definition) the cohomology of the derived Hom $\mathrm{RHom}_B(L_{B/A}, M)$. But if $P_\bullet$ is a simplicial cofibrant resolution of $B$ as an $A$-algebra, we have $\mathrm{RHom}_B(L_{B/A}, M) = \mathrm{Der}_A(P_\bullet, M)$ --- that's what the cotangent complex represents. If you write down what the first cohomology group of this thing is, like with the above examples, you'll get precisely the result you stated in the question.
By the way, one relation between Andre-Quillen cohomology and Hochschild cohomology comes from the Hochschild-Kostant-Rosenberg theorem, which says that if $k$ is of characteristic $0$, then the Hochschild homology $A\otimes_{A\otimes_k A^{op}}^\mathbf{L} A$ of a $k$-algebra $A$ is given by $\Omega^\bullet_{A/k} = \mathrm{Sym}^\bullet(\Omega^1_{A/k}[1])$. One can think of the Hochschild homology as the homotopy colimit of the constant $S^1$-indexed diagram (where $S^1$ is the simplicial circle $\Delta^1/\partial \Delta^1$) in simplicial $k$-algebras with value $A$, so there's an $S^1$-action on $\Omega^\bullet_{A/k}$. This defines a map $C_\ast(S^1; k)\otimes_k \Omega^\bullet_{A/k}\to \Omega^\bullet_{A/k}$ in the derived category of $k$-modules. But $S^1$ is rationally formal, and so $C^\ast(S^1; k) = k[d]/d^2$, where $d$ lives in degree $1$; the action of $d$ on $\Omega^\bullet_{A/k}$ is precisely the de Rham differential.
Before moving to central extensions, let me say that there wasn't much about derived categories of abelian categories that I used above, other than the facts that they have a notion of distinguished triangles which you can rotate (already true in triangulated categories) and that they are enriched over abelian groups (so taking cohomology of complexes makes sense). You can do all of these constructions more generally in stable model categories/stable $\infty$-categories, and in these more general cases, you recover the simple man's cohomology from algebraic topology 1.
More precisely, let's replace $\cA$ with the category $\mathrm{Sp}$ of spectra, so shifts are now given by suspension. We can then still form "derived Hom", i.e., the mapping spectrum. If $X$ is a spectrum, and $E$ is a spectrum, then $\Hom_\mathrm{Sp}(X, \Sigma^i E)$ is a perfectly well-defined spectrum, and its $\pi_0$ is just the cohomology group $E^i(X)$. Of course, you can replace $\mathrm{Sp}$ with, for instance, modules over a structured ring spectrum, and the same sort of construction holds. If your structured ring spectrum is the Eilenberg-Maclane spectrum associated to a classical ring $R$, then you'd be working in the derived category of chain complexes over $R$. It is important to remark, however, that the cotangent complex in this spectral world of a discrete ring regarded as a structured ring spectrum is not the same as the usual notion of cotangent complex: this is the distinction between topological Andre-Quillen cohomology and ordinary Andre-Quillen cohomology. (If $R$ is a $\mathbf{Q}$-algebra, then all is well and everything agrees with the classical notions.)
As Qfwfq states in the comments, the first, second, and fifth examples (in the order listed in my answer) can all be thought of as taking place in the category of sheaves over an algebro-geometric object. For example, $\mathrm{Mod}_R = \mathrm{QCoh}(\mathrm{Spec}(R))$, while $G$-representations on $\mathbf{Z}$-modules are $\mathrm{QCoh}(\mathrm{Spec}(\mathbf{Z})/G)$, where $X/G$ denotes the stacky quotient. For the fifth example, you have to work in the stable category of quasicoherent sheaves on the derived scheme $\mathrm{Spec}(B)$. In the third example, you'd be working in the stable category of left modules (in spectra) over $U(\mathfrak{g})$. In fourth example, you can do the same thing: the category of $A$-$A$-bimodules is the stable category of left modules (in spectra) over $A\otimes_k A^{op}$.
OK, what about central extensions and $\mathrm{H}^2$? Consider the case of the group cohomology $\mathrm{H}^2(G; M)$, where $M$ has a $G$-action. An element in this is given by a map $BG\to B^2 M$, which upon looping defines a loop map $G\to BM$. Let $L$ denote the fiber of this map; then, rotating this loop map defines a fiber sequence $M\to L\to G$ of loop spaces, i.e., a group extension. Moreover, the map $M\to L$ is central. Of course, this argument is pretty general, and you can run it in the Lie algebra setting as well.
As for obstruction theory: there's a lot to say here, and I've already written a bunch in this answer. However, this is the point of cotangent complexes: the recipe is to break down your obstruction theory problem into understanding extending along square-zero extensions, and then you're in the land of derivations. I can elaborate more if you'd like.