For reference this on on page 31 of the first edition of Concrete Mathematics by Graham, Knuth, Patashnik.
Let K be any finite set of integers. The commutative rule for sums is stated as follows: $$\sum_{k\in K}a_k = \sum_{p(k) \in K}a_{p(k)} \tag{2.17}$$
The function $p(k)$ in the general commutative law (2.17) is supposed to be a permutation of all the integers. In other words, for every integer $n$ there should be exactly one integer $k$ such that $p(k)=n$. Otherwise the commutative law might fail. Transformations like $p(k)=k+c$ or $p(k)=c-k$ where $c$ is an integer constant, are always permutations, so they always work.
On the other hand, we can relax the permutation restriction a little bit: We need to require only that there be exactly one integer k with $p(k)=n$ when $n$ is an element of the index set $K$. If $n \notin K$ it doesn't matter how often $p(k)=n$ occurs, because such $k$ don't take part in in the sum. Thus, for example, we can argue that
$$\sum_{\substack{k \in K \\ k \text{ even}}}a_k = \sum_{\substack{n \in K \\ n \text{ even}}}a_n = \sum_{\substack{2k \in K \\ 2k \text{ even}}}a_{2k} = \sum_{2k \in K}a_{2k} \tag{2.19}$$
Since there's exactly one $k$ such that $2k=n$ when $n \in K$ and $n$ is even.
What I don't fully understand is the funtion $p(k)$. It seems like $p$ is sort of like an array containing a permutation of the set $K$ and $p(k)$ is accessing element $k$ of the permutation, and $p$ is the same length as $K$, but I think my understanding of $p(k)$ is flawed and am asking for an explanation of what exactly $p(k)$ is and what the relaxation of the permutation restriction accomplishes.
I also don't see why the authors included $\sum{\substack{n \in K \\ n \text{ even}}}a_n$ in (2.19) as its the same as $\sum{\substack{k \in K \\ k \text{ even}}}a_k$ but using a different variable.