I have a problem where I have to move a third point between two points. The third point is not on the same line as the other two. It has to be moved between two points such that the distance remains the same in proportion. I have applied this
but due to distance not being the same after it comes on the line, it doesn't get placed in the desired position.
The picture will explain the problem better.



As I have finally understood, you are looking for the orthogonal projection of $(x_3,y_3)$ onto point $(x_4,y_4)$ which belongs to line segment [$M_1M_2$];
Therefore, we have to find the value of $a$ such that $M_4$ has coordinates :
$$\begin{cases}x_4=a x_1+(1-a)x_2\\y_4=a y_1+(1-a)y_2\end{cases}\tag{1}$$
such that distance $(M_3M_4)$ is minimal.
Let $$\begin{cases}X_2&:=&x_1-x_2\\Y_2&:=&y_1-y_2\end{cases}, \ \ \ \begin{cases}X_3&:=&x_1-x_3\\Y_3&:=&y_1-y_3\end{cases}$$
The looked for formula is :
$$a=\frac{-(X_2X_3+Y_2Y_3)}{X_2^2+Y_2^2}\tag{2}$$
that you just have to plug into (1).
Remark: you must have $0 \le a \le 1$. Otherwise, it means that the projection falls onto the line $[M_1M_2]$ but outside the segment.
Proof of (2): the squared distance between $M_3$ and $M_4$ is
$$(M_3M_4)^2=(a(x_1-x_2)+(x_1-x_3))^2+(a(y_1-y_2)+(y_1-y_3))^2$$
$$(M_3M_4)^2=(aX_2+X_3)^2+(aY_2+Y_3)^2$$
We then minimize it by expressing that its derivative with respect to $a$ is zero:
$$2a(X_2^2+Y_2^2)+2a(X_2X_3+Y_2Y_3)=0$$