The issue here is that market clearing can be defined in gross as well as in net terms.
Gross vs. net
Suppose I need 10 eggs for the next two weeks, and I don't intend to have any left over (I am going on vacation afterwards). I already have 3 at home, so I buy 7 at the local farmers market.
My gross demand was 10 eggs, this is how many I wanted given the current parameters.
My net demand was 7 eggs, this is how much I purchased from the market.
My net demand is my gross demand minus my endowment, thus in this case $10-3 = 7$.
Market clearing
Market clearing can be phrased in both gross and net terms. Let $x_i$ denote the gross demand of consumer $i$ for some good $x$, and let $\omega_{x,i}$ denote the endowment or gross supply of consumer $i$ of this same good $x$. Then the market for $x$ clears if
$$
\sum_i x_i = \sum_i \omega_{x,i}. \tag{1}
$$
This was phrased in gross terms: total gross demand equals total gross supply: every unit available was consumed by someone. (In the terms of the previous example you could say that I consumed 10 eggs; I bought 3 from myself and 7 from other agents.)
But we could also phrase market clearing in net terms. The net demand of consumer $i$ for good $x$ is
$x_i - \omega_{x,i}$. If this is a negative number, then consumer $i$ actually wants to sell, not buy this good, so they will have a net supply of $\omega_{x,i} - x_i$.
Let us denote the set of consumers with non-negative net demand by $I_D$, and the set of consumers with negative net demand/positive net supply by $I_S$, thus
$$
I_D = \left\{i | x_i - \omega_{x,i} \geq 0 \right\} \\
I_S = \left\{i | \omega_{x,i} - x_i > 0 \right\}
$$
It follows from $(1)$ that
$$
\sum_i (x_i - \omega_{x,i}) = 0.
$$
Splitting up the summation
$$
\sum_{i\in I_D} (x_i - \omega_{x,i}) + \sum_{i\in I_S} (x_i - \omega_{x,i}) = 0
$$
and rearranging the equation we have
$$
\sum_{i\in I_D} (x_i - \omega_{x,i}) = \sum_{i\in I_S} (\omega_{x,i} - x_i),
$$
thus total net demand equals total net supply. The steps are reversible, you can also start from net market clearing and prove that the market is also cleared in gross terms, so these two conditions are equivalent.