The same question (Find the cubic bezier control points from end points and tangents) had been asked some time ago but with no validated answer.
It is well known that if we denote by $V_0$ (resp. $V_1$) the initial (resp. final) vector, we have:
$$V_0=3\vec{P_0P_1}=3(P_1-P_0) \ \iff \ P_1=P_0+\frac13 V_0$$
and:
$$V_1=3\vec{P_2P_3}=3(P_3-P_2) \ \iff \ P_2=P_3-\frac13 V_1$$
(Proof below).
If the norms of the vectors are unimportant, you can multiply them resp. by arbitrary constants $k_0, k_1$ giving, instead of (1),(2), the more general solutions:
$$P_1=P_0+k_0V_0$$
and
$$P_2=P_3-k_1V_1$$
Briefly said: take for $P_1$ any point on the line defined by $P_0$ and direction given by $V_0$. The same for $P_2$.
Proof for (1) and (2): the current point on the cubic Bezier is:
$$P_t=s^3P_0+3s^2tP_1+3st^2P_2+t^3P_3 \ \text{with} \ s:=1-t$$
The speed vector is:
$$V_t=dP_t/dt=-3(1-t)^2P_0+3(1-4t+3t^2)P_1+3(2t-3t^2)P_2+3t^2P_3$$
If the given vectors $V_0$ and $V_1$ are interpreted as speed vectors, taking $t=0$ (resp. $t=1$) gives
$$V_0=-3P_0+3P_1=3\vec{P_0P_1} \ \ \text{and} \ \ V_1=-3P_2+3P_3=3\vec{P_2P_3}$$