I apologize for the slight abuse of terminology; I hope it will become clear what I mean below.
Consider a random variable $X$. Both the mean and the median can be characterized by an optimality criterion: The mean is that number $\mu$ that minimizes $\mathrm E((X - \mu)^2)$, and the median that number which minimizes $\mathrm E(|X - \mu|)$. In this perspective, the difference between mean and median is the choice of "metric" for evaluating deviations, the square or the absolute value.
On the other hand, the median is that number for which $\mathrm{Pr}(X \leq \mu) = \frac12$ (assuming absolute continuity), i.e. this definition depends only on the ability to order values of $X$ and is independent of how much they differ. A consequence of this is that for every strictly increasing function $f(x)$, $\mathrm{median}(f(X)) = f(\mathrm{median}(X))$, meaning it is "topological" in the sense of invariance under "rubber-like" transformations.
Now I've done the math and I know that starting from the optimality criterion I can arrive at the $\frac12$-quantile, so both describe the same thing. But still I am confused, because my intuition tells me that something that depends on a "metric" cannot lead to a "topological" property.
Can someone resolve this riddle for me?