The second equation is just the first equation with $K_i=0$. So the second equation would be a PD controller, while the first is PID controller.
One can derive the first equation by starting with common approximations for the integral $i[k]$ and derivative $d[k]$ terms
\begin{align}
i[k] &= i[k-1] + T_s\,\frac{e[k] + e[k-1]}{2}, \tag{1} \\
d[k] &= \frac{e[k] - e[k-1]}{T_s}. \tag{2}
\end{align}
The control signal could then also be constructed using
$$
u[k] = K_p\,e[k] + K_i\,i[k] + K_d\,d[k]. \tag{3}
$$
Your first equation can be obtained using the difference of the control signal and substituting $(1)$ and $(2)$
$$
u[k] - u[k-1] =
\left(K_p\,e[k] + K_i\left(i[k-1] + T_s\,\frac{e[k] + e[k-1]}{2}\right) + K_d\,\frac{e[k] - e[k-1]}{T_s}\right) -
\left(K_p\,e[k-1] + K_i\,i[k-1] + K_d\,\frac{e[k-1] - e[k-2]}{T_s}\right), \tag{4}
$$
namely expanding and simplifying this yields the same as your first equation
$$
u[k] - u[k-1] =
\left(K_p + \frac{K_i\,T_s}{2} + \frac{K_d}{T_s}\right) e[k] +
\left(-K_p + \frac{K_i\,T_s}{2} - \frac{2\,K_d}{T_s}\right) e[k-1] +
\frac{K_d}{T_s} e[k-2]. \tag{5}
$$
The advantage of using $(5)$ over the combination of $(1)$, $(2)$ and $(3)$ is that $(5)$ uses less computations and memory. However for debugging the other implementation might be more convenient, since $i[k]$ and $d[k]$ would be directly available. This would make it for example easier to check for integral windup or whether the derivative is staying within certain desired bounds.
However as TimWescott mentioned, the derivative term from $(2)$ can also be approximated with
$$
d[k] = \frac{1 + \alpha}{T_s} (e[k] - e[k-1]) - \alpha\,d[k-1], \tag{6}
$$
with $-1\leq\alpha\leq1$. Namely for values close to zero the magnitude of the transfer function associated with $(6)$ stays closer to that of a true derivative but the phase does drop significantly at high frequencies, while for values close to one the phase stays closer to 90° but the magnitude can increase a lot at high frequencies. It can be noted that $\alpha=1$ is equivalent to the bilinear transform. For negative values the transfer function looks like a high pass filter (pure derivative filtered by a low pass filter), which has the advantage of not amplifying high frequency noise. A similar thing could also be done for the integral, however the effects of an integral should only affect low frequencies, which is hardly affected by changing the parameter $\alpha$.
Using $(6)$ instead of $(2)$ does not allow for $(4)$ to be simplified down to $(5)$, due to the added pole from $(6)$, however one can write it into the following combined difference equation
$$
u[k] + (\alpha - 1)\,u[k-1] - \alpha\,u[k-2] =
\left(K_p + \frac{K_i\,T_s}{2} + \frac{K_d\,(1 + \alpha)}{T_s}\right) e[k] +
\left(K_p\,(\alpha - 1) + \frac{K_i\,T_s\,(\alpha + 1)}{2} - \frac{2\,K_d\,(1 + \alpha)}{T_s}\right) e[k-1] +
\left(-K_p\,\alpha + \frac{K_i\,T_s\,\alpha}{2} + \frac{K_d\,(1 + \alpha)}{T_s}\right) e[k-2]. \tag{7}
$$