Ok, will answer both of your questions here, you may want to merge them into one question.
The reason you are having problems is that you have heavily overloaded the word pair in your source document. So everything they are talking about is a pair. However, not all instances of word pair means the same thing. So while the chapter previous to this chapter talks about kinematic pairs, this chapter talks about kinematic chains. So the formula,
$$
l = 2 p - 4, \tag{1}
$$
talks about kinematic chains. It's a definition of sorts stating that: Number of links in a kinematic chain is number of link pairs minus 4. Now, it would be better if we would call link pair something else, in other literature this is often called a dyad. Which is smart because this is less confusing terminology as it underlines that we are NOT talking of kinematic pairs.
Ok so what is a dyad? A dyad is a pair of links connected end to end. Remember we are calculating chains. All non dyadic chains should be broken off for calculating purposes.
Image 1: Dyad vs no dyad
OK so the joint in a dyad needs to be a lower kinematic pair to count as a single joint. Still not counting joints but individual chain pieces. So how to handle nondyadic connections? Well you ignore them your not counting them.
Image 2: Calculating dyads when there is nondyadic connections. IT can be easily shown that there are 5 dyads in each direction
Counting the dyads. Count how may lkinks you can jump over form link to link. Either in just one direction or both (but your formula assumes only one direction is counted hence $2p$).
Image 3: Calculating dyads.
I find that talking about kinematic chains this way yields little to the conversation its just better to take Kuzbach mobility criterion and state that its a kinematic structure if the degree freedom is 1. As its easier to concentrate on type of joints instead of counting dyads. Kuzbach also becomes easier if you dont think of them as separate types of terms but think that each joint has a X freedoms locked and those are the basis for the freedom subtractions...