Some of Trump's poor standing among military officers obviously due to education. The service with the most PhDs is the Air Force, and that's the service where Trump polls worst with the officer corps.
But ...
Trump's divisive leadership is perceived by many officers as a direct threat to military effectiveness.
Hence the majority disapproval
Mattis' condemnation of Trump truly does matter. As does Powell's.