So I actually wrote my dissertation about this and it’s not just that the Department of Defence (there’s an office in the Pentagon dedicated to liaising with Hollywood productions), but they effectively have a strangle-hold on how Hollywood portrays the US military since the DoD give permission for producers to use military hardware, without that permission the cost of filming sharply goes up and films end up extremely over-budget. So the producers can either drop any critical elements at the DoD’s discretion, or continue with a film which will barely be released at all and will never make its budget back.
Any American film which involves the military, know that the DoD probably signed off on it, or were directly involved with. Films like American Sniper and Zero Dark Thirty had a heavy government influence, the latter to falsely justify the methods the CIA used in finding and killing Osama bin Laden, which included torture.
It’s why the military figures are always the heros and there will never be a Hollywood film which is critical of the US military because of this. Just remember, whenever you see the US military in a Hollywood movie, it’s exactly what the Department of Defence want you to see. It’s not being hyperbolic when these types of films are called propaganda.