In the last line of the proof, you can't apply the M-test in that way, because depends on . The M-test only applies if is a sequence of constants. If the function is bounded, say for all , then you can take . In that case, the M-test does apply and the conclusion is correct. In particular, if the space is compact, then will automatically be bounded and the result is correct.

But suppose for example that and . Then for all , but the convergence is not uniform.