I'm learning the proof of the expectation for a geometric random variable. The proof is as follows:
I just cannot understand the parts where I place two red boxes.
Why can we use differentiation here to get $\sum_{k=1}^{\infty }k(1-p)^{k-1}$?
Is there any theorem which I can follow?

Expectation describes the average value of a random variable.
$\begin{align*} E(X) = \begin{cases} \sum_{x} x \, p_X(x) & X \text{ is a discrete RV}\\ \int_{-\infty}^{\infty} x \, f_X(x)\, dx & X \text{ is a continuous RV} \end{cases}, \end{align*}$
If you go from the third step to the second in your linked image then it will be more clear. I think it is just more creative use of the differential operator. Think of the operator as a function that just maps denote a function which maps functions into their derivatives.