'Tptacek mentions a great list. What I'll add to that is that, contemporaneously, criticism of the military doesn't sell movie tickets. Nobody wants to watch a movie about how American soldiers might be put in harm's way for a bad reason, or might not behave honorably, at least not unless the event is historically removed enough that the audience can separate the message of the movie from their own family, friends, and kids on the front lines.
Agreed. Additionally, it's thematically popular that when part of the US military becomes the bad guy, it's usually limited to "those guys" and not the entirety of the Military. Typically "those guys" comes in the form of a well meaning but rouge unit, a General with a vendetta against an opposing force (i.e. hasn't gotten over the end of the Cold war), a traitor of some kind, an indifferent chain of command, etc etc.
These are things audiences will rally around. Behind Enemy Lines is an example[1].