If the military upholds their oath to the Constitution, we should never have a dictatorship.
That's why Trump just did a purge of top generals and lawyers in the military.
And that military action would be called a coup despite being the expected outcome of an attempted dictator.
The military getting involved is an absolute last resort type thing. And comes with risks of its own: military coups/juntas that started out as a legitimate dethroning of a dictator are not unheard of.