I'm not sure it is absolutely intended but it is at least an expected behavior: When you write f(x) = <expr>, SageMath actually creates a "callable symbolic expression" from <expr> (in which x is considered as a symbolic variable). This means that <expr> itself must initially be a symbolic expression (or anything that can be transformed into a symbolic expression). But this is not the case of divisors(n) since divisors is not a symbolic function applicable to a symbolic variable. Thus you must use the def ... return ... construction, or the equivalent lambda-expression f = lambda n: divisors(n).
In other words, there is a difference between a symbolic function, which is a Sage object made to represent mathematical functions (thus you can work with it, for instance derive it, integrate, etc.) and a Python function which is a function in the computer science sense, that is a subroutine. The shorthand f(x) = <expr> is a construction for symbolic functions and not for Python functions.