That is, if two distributions were the same, then their means would be the same as well.
Correct (assuming means exist), equality of distributions implies equality of means.
So if you're doing some hypothesis test where, under the null (and given any additional assumptions) the distributions are the same, the means will be the same.
But be careful; the implication doesn't go in the reverse direction.
Is there a difference between testing the equality of two means and testing the equality of two distributions?
Certainly! You need to consider what's going on with the alternative.
Imagine for example that under the null I have equality of distribution and then under my alternative the spreads can differ but the means remains the same. (To put it more carefully, the equality of location would be one of the assumptions rather than actually in the alternative)
Imagine that under the null both densities look like the black one below...
... but under the alternative one of them becomes more concentrated about the common mean, like the blue one.
There are a variety of possible test statistics for such a case, but most would be of little use as a test of equality of means.