Because you are using the math mode which has different syntax from the code mode (and the accessible in-scope functions and stuff are different), which results in occasional more narrow code mode switches for argument values like ratios, lengths, degrees, etc.
To clarify further: inside of an equation, as soon as you call a function with # in front as in #line(length: 20%), everything in the function call is in code mode, so 20% is parsed as a ratio just like in code. If you make the same call without # as in line(length: 20%) the function arguments are parsed in math mode so 20% is parsed as math content, like when you write $ 20% $.