I am sure this happens to every country (probably at a lesser extent).
I think heightening the training requirements and making so many background checks would be a good start to prevent this from becoming a much bigger issue. The heightened training requirements would be a natural wash-out of many future recruits, which will result in levels of gang members in the Armed Forces to decrease. The background checks will make it so much of a hassle to those who do not want to be in the military for the right reasons to stay in it (of course assuming no major corruption in the recruiters and those who take care of this job).
All in all, it will be hard keeping gangs from joining the military. If the 2nd Amendment wasn't there, I don't think we would have such a problem with gangs as we have now, yet so many people will fight for their rights to have a gun. People complain about violence in America, well, then ban the freaking thing causing a majority of it.
I am sure they will find some way to fix this. It is not good if a Gang member wises up on how to evade law enforcement because the military taught them how to. The military teaches how to use cover and other strategic things in gun fights. It can also heighten, awareness of gangs and make them harder to be convicted and make them more organized. This is indeed an issue that needs addressing, but I don't think it is so huge of a problem, that it needs to be bloated.
On a more off-topic view
Gangs are often hard to fight (especially in rich countries with so much freedom). So many gangs are attracted to US, because that is "where the money is at" and our justice system really tries to protect the people. If we were like China (law-wise), we wouldn't be having this problem to this extent. Don't get me wrong, I am not saying I support China's law and the way the enforce it. I am saying, US is so tolerant and loves freedom, maybe too much?
Ex. Too much freedom and your kids will do whatever they like whenever they feel like. That is basically how USA is.
Too strict and you can cause your kids to go rebellious (If someone tried tightening the US laws and such for the good of the people, the people will say its rights are threatened and can come to a rebellion quickly. Gun rights activist are an example, so paranoid about their guns getting taken, they speak like conspirators.)
It is hard to get that middle part of laws. US has had so much freedom for so long, any real way to fix its problems will cause a massive amount of unrest. We been off the leash too long...