I was trying to rewrite this equation in terms of $s$:
$$ p = 4s \frac{(s - 1)}{2} + s (2r + 1) $$
After failing at that, I tried with Wolfram Alpha, and got the answer I wanted. But, how did it get there? What are the techniques I should know to work with equations like this?
The techniques are the same as if there are only one or two variables, it can just get more confusing. You want to isolate $s$, so let's see:
$$\begin{align} p &= 4s\frac{s-1}{2}+s(2r+1) \\ &= 2s^2-2s+2rs+s \\ &=2s^2+2rs-s\end{align}$$
At this point, we can see that the equation is "quadratic in $s$", i.e., as far as that variable is concerned, it's a quadratic equation. Let's collect terms according to their degree in $s$:
$$2s^2+(2r-1)s-p = 0$$
Now you can apply the quadratic formula, using $2$ for $a$, $(2r-1)$ for $b$, and $-p$ for $c$.