I've always been taught to write $f : X \rightarrow Y$ as opposed to $f \in X \rightarrow Y$. This seems weird though, since $X \rightarrow Y$ can be viewed as the set of all functions with source $X$ and target $Y$, in which case the notation $f \in X \rightarrow Y$ has exactly its intended meaning.
Why do we write $f : X \rightarrow Y$? Is it habit? Notational prettiness? Historical accident?
Related. In category theory, we write $\mathrm{Hom}(X,Y)$ for the set of all arrows $X \rightarrow Y.$ Why do we not write $X \rightarrow Y$ for this set? Again, is this just historical inertia, or is there something deeper going on?
There would be at least two problems with the notation $f \in X \to Y$ instead of $f : X\to Y$ to mean "$f$ is a function from $X$ to $Y$."
In general it's bad for clarity to write things that have initial segments that mean unrelated things. Here "$f \in X$" is an initial segment of "$f \in X \to Y$" and if $X$ is a long expression, the reader might be surprised upon reaching the arrow and need to go back and re-interpret what came before it in light of what is ultimately claimed about the relationship between $f$ and $X$.
The arrow is also used sometimes for other things such as logical implication and convergence, so authors should make sure to provide contextual clues that enable the reader to resolve the ambiguity. The colon in the expression $f:X \to Y$ helps the reader understand what the arrow means. On the other hand, the notation "$f \in X \to Y$" is bad because $f \in X$ could be interpreted as a proposition, which is consistent with the use of "$\to$" to mean logical implication.