A cochain complex $(A^{\bullet}, d^{\bullet})$ is a sequence of abelian groups $\dots, A^{-2}, A^{-1}, A^0, A^1, A^2, \dots$ and group homomorphisms $d^k : A^k \to A^{k+1}$ such that $d^k\circ d^{k-1} = 0$. That is, we have a complex
$$\dots \xrightarrow{d^{-3}} A^{-2} \xrightarrow{d^{-2}} A^{-1} \xrightarrow{d^{-1}} A^0 \xrightarrow{d^0} A^1 \xrightarrow{d^1} A^2 \xrightarrow{d^2} \dots$$
As $d^k\circ d^{k-1} = 0$, $\operatorname{im} d^{k-1} \subseteq \ker d^k$. Furthermore, as the group $A^k$ is abelian, $\operatorname{im} d^{k-1}$ is a normal subgroup, so we can form the quotient group
$$H^k(A^{\bullet}, d^{\bullet}) := \frac{\ker d^k : A^k \to A^{k+1}}{\operatorname{im} d^{k-1} : A^{k-1} \to A^k}.$$
This is called the $k^{\text{th}}$ cohomology group of the cochain complex $(A^{\bullet}, d^{\bullet})$.
Note that $H^k(A^{\bullet}, d^{\bullet}) = 0$ if and only if the complex is exact at $A^k$ (i.e. $\operatorname{im} d^{k-1} = \ker d^k$). So we can view $H^k(A^{\bullet}, d^{\bullet})$ as a measure of how close the complex is to being exact at $A^k$ - that is, how close the inclusion $\operatorname{im} d^{k-1} \subseteq \ker d^k$ is to being an equality (the bigger $H^k(A^{\bullet}, d^{\bullet})$ is, the more elements of $\ker d^k$ there are which are not in $\operatorname{im} d^{k-1}$). From this point of view, it seems that considering $\ker d^k\setminus \operatorname{im} d^{k-1}$ is a much more natural thing to do. One problem with this approach is that while $A^{k-1}$, $A^k$, $\ker d^k$, and $\operatorname{im} d^{k-1}$ are all groups, $\ker d^k\setminus \operatorname{im} d^{k-1}$ is not a group whereas $H^k(A^{\bullet}, d^{\bullet})$ is. The group structure is very useful, which is why cohomology is defined as it is.
The example you gave, de Rham cohomology, is the cohomology of the cochain complex $(A^{\bullet}_{DR}(M), d^{\bullet})$ where $d^k : A^k_{DR}(M) \to A^{k+1}_{DR}(M)$ is the exterior derivative. Note that $\ker d^k$ is the set of closed $k$-forms and $\operatorname{im} d^{k-1}$ is set of exact $k$-forms, so $H^k_{DR}(M)$ measures how close the statement "every closed $k$-form is exact" is to being true.
Your first question seems to be:
Do all cohomology groups arise from taking the cohomology of a cochain complex?
What it means to be a cohomology group (or more precisely, a cohomology theory) can be defined axiomatically using the Eilenberg-Steenrod axioms.
While there are many different ways of defining a collection of cohomology groups $\dots H^{-2}, H^{-1}, H^0, H^1, H^2, \dots$, some of which are not defined as the cohomology of a cochain complex, there does exist a cochain complex $(A^{\bullet}, d^{\bullet})$ whose cohomology groups are isomorphic to the given ones: just take $A^k = H^k$ and $d^k = 0$, then
$$H^k(A^{\bullet}, d^{\bullet}) = \frac{\ker d^k : A^k \to A^{k+1}}{\operatorname{im} d^{k-1} : A^{k-1} \to A^k} = \frac{A^k}{0} \cong A^k = H^k.$$