$$ m\frac {d^{2}y}{d^{2}x} = 1 $$
homogenous linear equation for this ode is
$$ m\frac {d^{2}y}{d^{2}x} = 0 $$
trial solution is $Ae^{kx}$ but clearly in this case $Bx+C$ is a trial solution that works. What is the logic behind having 2 trial solutions only in this case? For every other problem I only guess the exponential solution.
Well, the trial solution is still $e^{kx}$ for some $k$ we should determine. Plugging it in, we get:
$$m\frac{d^2y}{dx^2}=0 \implies mk^2e^{kx}=0 \implies k^2=0 \implies k=0,0$$
So, the answer should be of the form $y(x)=Ae^{0x}+Be^{0x}=C$, for some constant $C$.
However, a second order linear ODE should have two linearly independent solutions. As such, it turns out that whenever we have a repeated solution like the above, we can get another solution by multiplying the current one by $x$.
Indeed, we find that $Dx$ is also a solution.
Hence, the general solution is $C+Dx$