This is actually explicitly mentioned in the rulebook, on page 6, under Epidemics:
2) Infect: Take the bottom card from the Infection Draw Pile and add 3 cubes to the city pictured on the card, then place the card into the Infection Discard Pile. Note: No city can contain more than 3 cubes of any one colour. If the Epidemic would cause the city to exceed that limit, any excess cubes are returned to the stock and an outbreak is triggered. See rules for Outbreaks on page 7.
Note that this is only one outbreak:
any excess cubes are returned to the stock and an outbreak is triggered
If Mumbai has 2 black cubes, and comes up during the Infect phase of the epidemic, Mumbai only outbreaks once, and ends up with 3 cubes. Of course, this outbreak might cause chain reactions as usual (which, as usual, cannot cause Mumbai to outbreak a second time during the chain reaction).
The best way to prevent this situation is to keep track of the cities that might outbreak (3 cube cities that aren't in the infection discard pile, or if the infection discard pile is getting large, all 3 cube cities), and reduce them to 1 cube cities. I think it's also important to deal with cities that have just had outbreaks - since if they pop again, there will be a large group of interconnected 2/3 cube cities, leading to the loss situation you describe.
Keep in mind that the particular draw of the setup, affects the difficulty a lot - in my opinion, much more than the number of epidemic cards in the deck. One way to deal with this is to choose the number of epidemic cards to play with after you've set up the initial infected cities.