We give high-schoolers many different explanations of the word "function." Here are a few that are either implied or outright stated at various points in a student's education:
- A function is an expression in terms of $x$. This is pretty unusual all by itself, but it may appear in conjunction with (2) or (3) (i.e. students may reason that $f(x)$ or $y$ is the function, and since $f(x)$ equals some expression, therefore the expression is the function too). Students may become uncomfortable if the variable is not $x$.
- A function is an equation of the form $f(x) = \mathrm{[something]}$, where [something] is in terms of $x$. Students may believe that the function can be subsequently "abbreviated" as $f(x)$. If there is also a $g(x)$ and you're teaching function compositions, then there will often be confusion about how $x$ can have "multiple different values" (i.e. when you write $f(g(x))$, the value that is given to $f$ is "not the same" as the value that is given to $g$, but some students may believe that both values are $x$ because that's how $f(x)$ is written); students may reconcile this by blindly applying the correct substitution without understanding what they are doing. But it gets them points on the exam or homework, so the student thinks they are learning.
- A function is an equation of the form $y = \mathrm{[something]}$, where [something] is in terms of $x$. Students may believe that it specifically has to be $x$ and $y$, in the right order, rather than any other pair of variables.
- A function is a set of ordered pairs $(x, y)$, such that no two (distinct) pairs have the same $x$. The word "distinct" is often omitted from this definition, but it probably doesn't matter in practice because students are generally going to assume that's what it means anyway.
- As in (2), but allowing for piecewise notation. Students may believe that piecewise functions are somehow "less valid" than "regular" functions, and/or try to rewrite piecewise functions as non-piecewise functions. For that matter, students believe that there is a such thing as "a piecewise function" in the first place.
- As in (3), but allowing for implicit functions. Again, students may resist implicit functions, but solving an implicit function for $y$ is at least a useful activity some of the time.
All of these definitions are at best incomplete and at worst outright wrong. (4) is somewhat close to being right, but like all of these definitions, it does not supply a codomain and therefore cannot explain the concept of a surjective function (for example, if you take the floor function over $\mathbb{R} \rightarrow \mathbb{R}$, it is not surjective, but if you take it over $\mathbb{R} \rightarrow \mathbb{Z}$, it is surjective, yet both of these functions contain exactly the same set of ordered pairs in their respective graphs). Unlike the other definitions, (4) does imply a specific domain - the domain is just the set of $x$ coordinates. However, students might not notice this subtlety, and the existence of the other (wronger) definitions tends to deemphasize the idea that the domain can be chosen arbitrarily. (4) is also incompatible with algebraic and (for the most part) analytic manipulation, so students will have to work with the other definitions regardless of what they think of (4).
There is one exercise at the high-school level that does describe functions more or less correctly, but it tends to get neglected in favor of the definitions given above. It usually looks like this: Students are shown a diagram with two adjacent ellipses or circles, each containing a small number of labeled points, and arrows from points in the left ellipse to points in the right ellipse. Students are then (correctly) told that these diagrams show (binary) relations, and are typically asked to identify which relations are functions, one-to-one, etc. These diagrams contain all of the required elements of a function, including the codomain. However, this visualization is usually dropped in favor of the so-called "vertical line test" (i.e. draw vertical lines through the graph of a function, and make sure that each line intersects the graph at most once) and "horizontal line test" (the same, but with horizontal lines), which can be used on infinite relations/functions (unlike drawing out an explicit relation diagram one point at a time). I suspect that many students prefer the vertical/horizontal line tests, because they are specific "recipes" that students can use to "get the right answer" and do well on exams or homework (whereas trying to visualize infinitely many arrows between points is going to be difficult at best).
The other serious problem at the high-school level is that most students don't properly appreciate the distinction between $f$ and $f(x)$. Of course, mathematicians often ignore this distinction as well, because it's a rather fine and technical distinction which only sometimes matters, but many students are not even aware that there is a distinction to be drawn in the first place. If you cannot even write $f$ by itself without confusing half the class, how do you expect them to understand $f: A \rightarrow B$?
TL;DR: We don't give students a proper explanation of "domain" because we don't give them a proper explanation of "function," and that in turn is because of high-school's emphasis on algebra, graphing, and other specific ways of applying the math, rather than on a broader conceptual foundation.