There are many more ways to get to torture. The rat could go $1 \to 2 \to 3 \to 2 \to$Torture for example. One way to solve it would be to account for all the ways and compute the probability of each. The approach taken in the article is to recognize that the probability of getting to Torture only depends on what room the rat is in, not on the history of how it got there. The variable $p_2$ is the probability that the rat eventually gets to torture starting in room $2$. The equation $p_2=(1/4)p_1+(1/4)1+(2/4)p_3$ represents the fact that from room $2$ the rat has $1/4$ chance of moving directly to room $1$, followed by a $p_1$ chance of getting to Torture from room $1$, a $1/4$ chance of going directly to Torture and a $2/4$ chance of moving to room 3 with a $p_3$ chance of eventually getting to Torture. This produces the set of three simultaneous equations that are shown, and the solution is also shown.