How does the definition of electrical power follow from the chain rule?
You got the chain rule wrong. It actually is \$f'(g(x))g'(x)\$. Write the work as \$W(q(t))\$ and derive it to obtain the power. Be aware that \$W\$ is written as function of \$q\$, so \$W'=\frac{dW}{dq}\$.