To answer your second comment/observation first.
Why would the scribe have done that if he could simply transfer the last word to the next line
Multiple reasons, including:
- What you saw was a correction; he missed a word and had to put it in after it was proofread.
- He was following a standard layout and didn't want to start guessing how to continue. Sometimes the original templates (like The Blue Tikun) have lines that are way too full.
- He was getting close to one of those rare locations where you have to start the column with a specific word, as described in this answer.
That linked answer answers your more general query: A Sofer has a lot of leeway, though there are certain words (in 6 places) that need to be at the start of a column, by tradition.
And you have to follow the paragraph style, of which there are 2:
- The one marked in the Chumash as a פ - there are various opinions and multiple laws but traditionally in a standard Sefer Torah each פ paragraph ends in the middle of a line - with empty space after the end of the paragraph to write at least 9 letters.
- The one marked in the Chumash as a ס - by traditions in a classic Sefer Torah the paragraph ends on the same line as the next paragraph begins - with at least a 9-letter break between the paragraphs.
Then there's the Shira in Beshalach and Haazzinu that have a very strict layout, traditionally.
Finally, by tradition, each column (except for the 6 exceptions) begins with a Vav.
(As to where the line is between strict Halacha, Minhag and that's the classical way to do it is beyond the scope of this answer. I simply fudged it by referring to it as tradition.)