I know that a vertical line has infinite outputs. For that it cannot be a function. What about horizontal lines? Because a horizontal line has only one output.
Yup. It represents a function that gives the same output no matter what input you give it. Usually written as $f(x)=a$ (so, for instance, $f(x)=5$ is one such function), and called a constant function.