The Mann-Whitney U test is a non-parametric test meaning that it is, loosely put, counting up hits and misses for rankings with the point being that the number of outcomes is countable as opposed to real continuous like a $t$-statistic. With some simplification the number of outcomes is $\frac{n(n+1)}{2}$ or the number of combinations of $n$ objects taken two at a time, and in practice, some of those combinations yield a $p=1$. What this does is to limit the number of possible probability values a U-statistic can output such that a perfect $p=1$ merely means that no difference was detected as the countable events matched. The $p=1$ is an accidental outcome, that is, it does not have the same meaning as it would in a deterministic system, and even suspected to be deterministic systems suffer the black swan problem. That is, just because the probability of seeing only white swans might seem like $p=1$, doesn't make that estimate hold for a larger dataset. That is, one needs a solid physical reason for calling a system deterministic, and guesswork alone cannot provide that. As it is, the outcomes for the Mann-Whitney U test are countable, each outcome is only approximate.
Couldn't help but notice the discussion above. Here is a worked example of what the Mann-Whitney U test does. In that file, one can see that the Mann-Whitney U test tests differences in location of the data sets using a fairly comprehensive comparison of rankings. The concept of location of data is a more general one than mean or median. The best measure of data location can be thought of as the minimum variance unbiased estimator of data location MVUE. For example, for a uniform distribution of unknown population endpoints, the average extreme value $\frac{min(x)+max(x)}{2}$ of $x$-values is a lower variance estimator of location than either the mean or median, despite the fact that for uniform distributions all three measures tend to the same location in the limit as the number of observations increases unbounded large.
The Mann-Whitney U test, has as its most important feature is that it is an unbiased test of difference of location as it ignores non-normality. Finally, the difference of location measure of the Mann-Whitney U test is...wait for it...the U-statistic.
The theory of U-statistics allows a minimum-variance unbiased estimator to be derived from each unbiased estimator of an estimable parameter (alternatively, statistical functional) for large classes of probability distributions. If $f(x_1, x_2) = |x_1 - x_2|$, the U-statistic is the mean pairwise deviation
$f_n(x_1,\ldots, x_n) = \sum_{i\neq j} |x_i - x_j| / (n(n-1))$, defined for $n\ge 2$. That theory explains that the U-statistic is MVUE for the median of data triplets and not of $n$ data samples.