Hey Zachary,
I just recognized that German is quite difficult when it comes to "with" because we have more than two words for it. So I'll try to explain it to you.
Both "mit" and "bei" are prepositions but they are used differently. In your first example "Ich helfe dir bei den Hausaufgaben" you can choose both, i. e. "Ich helfe dir mit den Hausaufgaben" does say the same as your original example. Here you can choose "mit" or "bei" because you are trying to express an active participation in a process or action.
Your second example expresses something spatially. It says, that some speakers A, B and C are in the near of / same room as/ etc. listener D or D and E.
Unfortunately "bei" and "mit" does have a lot of meanings in german, so you need a dozen of examples to get a feeling for it.