The problem I am looking at comes from a STEP paper and is as follows
I managed to do the first part correctly, however, I was unsuccessful in doing the second part. The answers say that we should have
however, shouldn't the expectation be $\sum x P(X=x)$? I don't understand how they got their formula. I see that they summed the winnings for that ammount of people times the probability of that many people wining but I don't know why this gives the expectation (as it seems to differ from the aforementioned formula). Could somebody explain why this is the case and what is the basic principle for future reference?


It seems to me the fundamental problem is how you read the formula $\sum x P(X=x)$.
If you are taking the expected value of a binomial distribution (for example), let's say the binomial distribution for $n$ trials with probability $p,$ you would take the sum like this:
$$ E(X) = \sum_{x = 0, 1, 2, 3, \ldots, n} x P(X=x). $$
This is because the possible outcomes of the binomial distribution are $0, 1, 2, 3, \ldots, n.$ These are the possible values of "number of successes" in a sequence of $n$ trials. It is not possible to have the outcome $\frac12$ or the outcome $\frac{17}3.$
In short, to get the expected number of successes, you take each possible number of successes and multiply by the probability of getting that number of successes, and add up all those products.
But this problem is not asking for an expected number of successes. It is asking for expected net loss. Since net loss is the same as the cost ($N$) minus the net winnings, the answer is also $N$ minus the expected winnings, which is how other people are answering this question.
But the possible values of the expected winnings are not $0, 1, 2, 3, \ldots, n.$ The possible winnings are $W$ (if no other ticket wins), $W/2$ (if one other ticket wins), $W/3$ (if two other tickets win), and so forth.
So to get the expected winnings, you take each possible amount of winnings and multiply by the probability of getting that amount of winnings, then add up the products like this:
$$ E(X) = \sum_{x = W, \frac W2, \frac W3, \ldots} x P(X=x). $$
And that is exactly how people are solving this problem.