It was frustrating to read that Wikipedia page. Rather than explaining every single problem with it, I'll only mention the top three problems in the single paragraph that you quoted (if there's this many problems with one paragraph, you can imagine how many can be listed across the rest of the article spanning several dozen paragraphs):
- You already noticed that the article switches $N$ and $M$.
- They then talk about $W$ without ever defining it explicitly.
- They don't cite references, and therefore even if it is indeed a "simple" counting argument that leads to their Hilbert space formula, anyone who does not know much about quantum photonics (specifically, how to determine the size of the Hilbert space in this situation) will simply have to take that formula for granted.
However, at least the formula they gave for the Hilbert space does happen to be correct, even if they didn't explain why and didn't cite a reference (I thought citations were a requirement in order to put things in Wikipedia?). This paper published as an "Editor's Suggestion" in Physical Review Letters fortunately does give the formula for the Hilbert space (all you have to do is search for the string "Hilbert space"), and it's the same as in Wikipedia. So even if you still know zero about quantum optics, at least you're no longer worried that there's no published citation that backs up the claim.
If the Hilbert space were to be $2^N$, then the complexity would be precisely the same no matter the size of $M$, so the Hilbert space does need to depend on both $N$ and $M$.
Furthermore, you can see in the above-mentioned paper published in PRL, that the abstract mentions a Hilbert space of $10^{14}$ which is (now that their $n$ is our $M$ and vice versa):
- not $2^N = 2^{60} \approx 1.15 \times 10^{18}$, and
- not ${M+N-1 \choose M} = {79 \choose 20} \approx 2.65 \times 10^{18}.$
Instead, the $10^{14}$ that they state, comes from ${M^\prime+N-1 \choose M^\prime} \approx 3.697 \times 10^{14}$ where $M^\prime=14$ instead of 20, because there's only 14 outputs, despite their being 20 input photons.
This is sometimes called the "output Hilbert space" which can be smaller than the Hilbert space of the actual physical wavefunction.