This is what @perepujal tried to explain.
When you enter
5,0 this is an absolute coordinate. And this is a movement of 1,0 from your reference point at 4,0.
When you want to move 5,0 you have to enter
@5,0 which then is a relative coordinate, related to your reference point at 4,0.
Otherwise don't snap to the line for the first reference point, enter 0,0
or with Grid Snap click on the absolute origin at 0,0, then you can enter 5,0 without
@ for target point.
For a detailed explanation see
https://librecad.readthedocs.io/en/latest/ref/fundamentals.html?highlight=relative#defining-coordinate-locations
investing less than half an hour into Search function can save hours or days of waiting for a solution