Consider the case if m is even and all the k values are all even. Then, the hash values will also all be even.
For example, consider the case m=6 hashing even values:
Input values: 0, 2, 4, 6, 8, 10, 12, 14, 16, ...
Hash values: 0, 2, 4, 0, 2, 4, 0, 2, 4, ...
If you use these hash values as indices into a table, then half of the table will be unused. On the other hand, if m is a prime, you will get an even distribution of the hash values, even if the input values all have a common factor.
Consider the same input values, but with m=7:
Input values: 0, 2, 4, 6, 8, 10, 12, 14, 16, ...
Hash values: 0, 2, 4, 6, 1, 3, 5, 0, 2, ...
Despite the fact that the input values are all even, the hash values are still uniformly distributed over [0..6].
So to summarize, if m is prime, then you'll still get an even distribution of hash values even if all input values are divisible a common prime factor (other than m).