No self-interaction in the exact functional
The electronic structure Hamiltonian in real space is
$$\tag{1}
H = T + V_{ee} + V_{\text{ext}} = -\frac12 \sum_i \nabla_i^2 + \sum_{i<j} \frac{1}{\lvert r - r' \rvert} + V_{\text{ext}}(r),
$$
where $i, j$ index the electrons in your favorite system.
The relevant term is the electron-electron interaction $V_{ee}$, and especially the index in its sum: $i < j$ means that electron $i$ does not interact with itself.
Because the (unknown) Hohenberg–Kohn functional is exact, it must replicate the behavior of the Schrödinger equation. No self-interaction is part of that.
Self-interaction in Hartree–Fock theory and Kohn–Sham DFT
Neither Hartree–Fock (HF) theory nor Kohn–Sham DFT calculate $V_{ee}$ directly. HF approximates the electron-electron interaction between one-particle orbitals $\lvert \psi_i \rangle$ and $\lvert \psi_j \rangle$ as
$$
\begin{align}
\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\ \langle \psi_i \vert V_{ee} \vert \psi_j \rangle &\small{\approx J[\psi_i, \psi_j] - K[\psi_i, \psi_j] }\tag{2}\\
&\small{= \iint dr\, dr'\, \frac{\psi_i^*(r) \psi_i(r) \psi_j^*(r') \psi_j^*(r')}{\lvert r - r' \rvert} - \iint dr\, dr'\, \frac{\psi_i^*(r) \psi_j(r) \psi_j^*(r') \psi_i(r')}{\lvert r - r' \rvert}.}\tag{3}
\end{align}
$$
$J$ is called the Hartree energy (it's the classical electrostatic repulsion) and $K$ is called the exchange energy; they differ by a swapping of indices. A notable property of HF is that $J[\psi_i, \psi_i] - K[\psi_i, \psi_i] = 0$, as you can verify by inspection. For this reason, HF theory is said to be self-interaction–free.
Kohn–Sham DFT's treatment of $V_{ee}$ is not as simple; it's something like
$$\tag{4}
\langle \psi_i \vert V_{ee} \vert \psi_j \rangle \approx J[\psi_i, \psi_j] + E_{xc}[\rho],
$$
except that the exchange-correlation energy $E_{xc}$ also includes some information about the many-body kinetic energy. But you can check whether a one-electron system, like the hydrogen atom, actually satisfies $J[\psi_1, \psi_1] - E_{xc}[\rho] = 0$ for a given density functional approximation's $E_{xc}$: usually the answer is no. This is usually called self-interaction error.
Bonus: Many-electron self-interaction error
There are actually some density functional approximations, such as those described here, that are free of (one-electron) self-interaction error, just like HF is. However, they still suffer from most of the DFT problems traditionally associated with self-interaction error: too-small band gaps and reaction energy barriers, overly delocalized charges, and so on. This more general issue with DFT is known as delocalization error (it's sometimes been called many-electron self-interaction error too!) and mitigating it is an active area of research.