Let's go with an example, you are MITM.
- Alice sends Bob the prime number and the base, ie: p=23, g=5.
- But... MITM changes p and g to 29 and 7.
- So Bob agrees with Alice using p and g 29 and 7.
- MITM man now can't change Bob response so it just send Alice 29 and 7.
Two options now, Alice can reject the 29 and 7 since they are not the original values and begin the negotiation again or Alice sends an acknowledgement to Bob for 29 and 7 values, let's consider the second option, since the first option ends up with no communication.
- Alice agrees to use 29 and 7 as new P and G and select a secret number.
- MITM now only can look and he will never now the secret number Alice has chosen. He can try to bruteforce, but that can take time and that is not the matter discussed.
So, in this case it doesn't really matter who chooses the prime numbers, in fact they could be public.
(It can actually compromise the communication by choosing very low prime number as 2 and 3 since a brute force attack to these number is actually easy, but I guess most algorithms will force big prime numbers).
As a last note, if the implementation is really buggy (as @GeneVincent suggest) and allow very low prime numbers, then you got it. You can listen the communication easily.