In the example $$\lim_{x\to 1}(2x+3)=5$$
you have $f(x) = 2x+3$ and $L=5,$ so as you showed, you write
$$\lvert f(x)-L \rvert = \lvert (2x+3)-5 \rvert = \lvert 2x - 2\rvert. $$
You also have $a = 1,$ so $\lvert x - a \rvert = \lvert x - 1 \rvert.$
So if you notice that $\lvert 2x - 2\rvert = 2\lvert x - 1\rvert,$ you will have discovered that
$$\lvert f(x)-L \rvert = 2\lvert x - a \rvert. $$
Since the left and right sides of this equation are equal quantities, we know that
$\lvert f(x)-L \rvert < \epsilon$ if and only if $2\lvert x - a \rvert < \epsilon,$
while $2\lvert x - a \rvert < \epsilon$ is true if and only if
$\lvert x - a \rvert < \frac\epsilon2$.
Since each of these inequalities is true if and only if the others are true,
we can work backwards from the end:
If $\lvert x - a \rvert < \frac\epsilon2$ then $2\lvert x - a \rvert < \epsilon.$
If $2\lvert x - a \rvert < \epsilon$ then $\lvert f(x)-L \rvert < \epsilon.$
Therefore, if $\lvert x - a \rvert < \frac\epsilon2$ then
$\lvert f(x)-L \rvert < \epsilon.$
That is the implication in the definition of $\lim_{x\to a}f(x) = L,$ except that we have $\frac\epsilon2$ where the definition has $\delta.$
So for any $\epsilon > 0,$ we know that there is a number that we can call $\delta$
and that happens to be equal to $\frac\epsilon2$ such that
$\lvert f(x)-L \rvert < \epsilon$ whenever $\lvert x - a \rvert < \delta.$
And that is exactly the definition of the limit.
I think it is important to remember that the step of "finding $\delta$ in terms of $\epsilon$" is a technique to help you prepare to write a delta-epsilon proof;
it is not part of the proof itself.
Indeed, if you were very lucky and guessed (without doing any calculations at all)
that you could set $\delta$ equal to $\frac\epsilon2$ in your proof,
you would find when you wrote the proof that this actually worked as desired.
But most of us are not such lucky guessers, so we need a little calculation to help us with the guesses.
But there is no general method (at least none I am aware of) to tell you how to manipulate any arbitrary differentiable function $f(x)$ in order to find the derivative of $f(x)$ at any particular value of $x.$
You might be able to generalize the method above to work for any linear function,
but you will need a different method for a quadratic function,
another for an exponential function, etc.
So even with these techniques, the answer to "how did you know" is generally that you did not know how to do it when you started, but you used intuition, experience,
and sometimes trial and error (the manipulation looked like it would get you a suitable way to express $\delta$, but it did not) until you found a proof that worked.