The key things to remember about a function is this: one input, one output.
The input must be in the domain of the function. The domain is the set of allowed inputs (eg: you must avoid dividing by zero).
If an input like x = 4 leads to simultaneous outputs of y = 1 and y = 5 at the same time, then we don't have a function. Visually this leads to the graph failing the vertical line test. A single straight line cannot pass through more than one point on the curve.
So if it is impossible to have a single straight line pass through more than one point on the curve, then that curve is a function.