Because length/1 ist only defined for lists, not binaries.
You need to check byte_size/1 or String.length/1 but beware of the semantic differences.
The first one will return the number of bytes in the string and has constant runtime, while the latter has to iterate over the full string to count the graphemes in the string.