You are seeking to solve the underdetermined system of linear equations $\mathbf{A} \mathbf{p} = \mathbf{m}$ subject to the additional constraint that $\mathbf{p}$ must be a probability vector (i.e., $p_i \geqslant 0$ and $\sum p_i = 1$). Finding a useful characterisation of the full set of solutions is quite a difficult programming problem, but it should be fairly simple to find a single solution in a particular case. For the latter problem, assuming there is a solution that is not at a boundary point (which will usually be the case), all you really need to do is to get to a point that is "close" to a solution point that obeys the required constraints and then use this to fix $M-k+1$ of the values in the system, and then solve the remaining values using a standard fully-determined system of linear equations.
There are many ways to solve this problem. One way is to rewrite it as an unconstrained non-linear problem, and iterate towards a solution. To do this, define the unconstrained vector $\mathbf{r} = (r_1,...,r_M) \in \mathbb{R}^M$ (and let $r_0 \equiv 0$) and use the softmax transformation to obtain the associated probability vector:
$$p_i = \frac{\exp(r_i)}{1+\sum_{j=0}^M \exp(r_j)} \quad \quad \quad \text{for } i = 0,...,M.$$
You can then write your moment equations as:
$$m_a = \frac{\sum_{i=1}^M i^a \cdot \exp(r_i)}{1+\sum_{i=1}^M \exp(r_i)} \quad \quad \quad \quad \quad \text{for } a = 1...,k. $$
You can use non-linear programming to iterate towards a solution to this system of non-linear equations, and thereby obtain a point $\hat{\mathbf{r}}$ that is close to a solution point. Create the corresponding probability vector $\hat{\mathbf{p}}$ and take the values $\hat{p}_k,...,\hat{p}_M$ from this vector. You now have a fully-determined system of linear equations $\mathbf{A} \mathbf{p} = \mathbf{m}$ where the values $\hat{p}_k,...,\hat{p}_M$ are fixed.
Assuming that there is a solution to your system that is not on the boundary point, it should be the case that there will be a solution that is "close enough" to $\hat{\mathbf{p}}$ so that holding its last values constant gives a solution point from the corresponding system of linear equations. If you add some specific numbers to your problem then it should be fairly simple to find a solution by this technique.