I don't understand why question 'How many people came to your party?' is correct instead of 'How many people did come to your party?'. Is it any grammar rule?
Either may be correct. *How many people did come?* is contrastive: it would be appropriate if your hearer had been talking about the people who didn't come. But without some such context, do support is unnecessary because the interrogative phrase, how many people, acts as the subject of the question: when that is the case, there is no inversion or do support.
Who came?, not Who did come?, except in contrastive contexts, but
Who(m) did you invite?, not Who(m) you invited?, because here who is the object of invite.
Either sentence would be grammatically correct, but it is more common to hear "How many people came to your party?"