Definition 1. Given a set $S$, the identity function on $S$ is the function $id_S:S \to S$ that maps any element $x \in S$ to itself.
Proposition. Given a type $S$, the identity type for $S$ is the constructor $id_S:S \to S$ that maps any value $x:S$ to itself.
Proof Sketch. A type can be a set. A function can determine the members of that set. Such a function defines the type; a constructor. An identity type under such an interpretation would be a set comprised only of neutral elements of $S$. As before, it is also determined by the function that characterizes it. It behaves as a mapping that does not change the value of any possible inhabitant of $S$. So, $id_S(x:S)=x:S$ is an identity function mapping $S→S$.$$\tag*{$\blacksquare$}$$
My question is whether this holds.
No, the identity type of $S$ is, of course, a type. It is not a term of type $S \to S$.
For any type $S$ the corresponding identity type, which I will call $\newcommand{\Id}{\mathrm{Id}}\Id_S$, is a dependent type that depends on two terms of type $S$. This means that given $x:S$, $y:S$, there is a type $\Id_S(x,y)$; which you might vaguely think of as the "collection of reasons that $x$ and $y$ are equal".
Notice that this identity type is something like a function $\Id_S : S \times S \to \mathrm{Type}$, where $\mathrm{Type}$ is some sort of "type of all types". In particular notice that $\Id_S$ is not a function $S \to S$!
Type theory$^1$ is formal system with rules describing things you can talk about (types and terms) and things you can say about them (judgements). You don't need to interpret types at all! But there are also interpretations of type theory and thinking of them can help build intuition (up to a point!). If you want to interpret types as sets, then what could this $\Id_S$ be? Well, you could interpret it as a sort of Kronecker delta: in one interpretation, given $x:S$, $y:S$ (i.e., $x,y \in S$), $\Id_S(x,y)$ is $\mathbf{1} = \{\ast\}$ (a set with one element) if $x=y$ and it is $\mathbf{0} = \emptyset$ otherwise.
That is not the only interpretation of type theory, though. And thinking they are all like that is definitely misleading.
In that interpretation, if $e_1$ and $e_2$ are of type $\Id_S(x,y)$ they are automatically equal! Or in other words, if $\Id_S(x,y)$ has any points at all, it only has one. There are very interesting interpretations of type theory that do not have that property.
$^1$ Or maybe I should say type theories, as there are various related kinds.