I live in two separate worlds simultaneously. Here is what I have observed, but please bear in mind the following points are easily abused by incompetent superiors to protect themselves.
1. Corporate:
1a. Subordinates: In the corporate world firing people isn't as easy as it sounds. Put everything on paper. Good managers have lots of paper on their people. Good documentation lets you know who to promote, without implicit bias, versus who to fire if layoffs happen. This is why contractors are so common at many firms. Contractors are easy to fire.
1b. Managers: There are great managers and there are horrid managers. More often than not it comes down to personality. Does your manager know anything about you? Do they listen to you or care about your job? Good managers really show they care. No matter how much you suck they still want to provide you opportunities to propel your career. Incompetent managers look you are a line item. In the case of incompetent managers you aren't going to be a rockstar. Instead cover all your bases and check off all the blocks on the metrics the boss cares about. The goal is to tread water with comfort and not make waves. In this case a life raft is any opportunity to work under a different manager.
1c. Peers: Tread carefully.
1c I. Incompetence: Incompetent peers who are downing might try to pull you down with them. Don't let incompetent people dictate your quality of work. Be independent and grow a backbone in the face of their uncertainty. Always be helpful with frequent offers of assistance and guidance. Help them to learn and remain productive, but the bottom line is to deliver quality work to the project on time.
Ic II. Assholes: If they are assholes or too special for help then simply let them drown. If they do stupid things to harm product quality let the product owner know, but remember you are not their boss. If they don't make it at the current company they will always find work somewhere else.
1C III. Immaturity: Immaturity is rampant among young developers. Its weird how so many young developers, even when I was young, think they are so incredibly talented. I believe this is the dunning-krueger effect effect. Kindly remind the immature person when they step out of bounds, but keep a very safe distance. Typically immaturity stems from a lack of self-awareness similar to starting forest fires.
2. Military:
2a. Subordinates
2a I. Disobedience or Disrespect: Eliminate the problem immediately and directly in a very ad hoc manner. This is ok because they are owned by their superiors. The superiors must then care for them with directed guidance and mentoring. After you crush their emotions you have to empower them to make better decisions independently.
2a II. Incompetence: Counsel them on paper. Every major screw up goes on paper. This protects you and them, because lets your booses know you are working on it and maybe they need a different job. You need paper to prevent them from being promoted before they are ready. Putting things on paper with great specificity also imposes an action plan upon you to improve the individual.
2b. Superiors
2b I. Assholes. Pull them aside and kindly let them know they are burning all their bridges and although they don't see it yet they are drowning and nobody wants to save them. Give them an olive branch and be patient and respectful while they are being an asshole to you. Be a good example and encourage them to follow your lead before they really hurt themselves.
2b II. Toxic Leaders. The core of all toxic leadership is some sort of selfish quality. Document all the wrongs you see about them. Simultaneously report the evil bastard to the unit commander and let the unit commander you have already submitted the issue to the inspector general's office. Don't wait on this and don't be passive about it, because if they aren't screwing you they are screwing somebody else. This is one of those situations were the forced dichotomy isn't a fallacy. You really are part of the solution, part of the problem, or an immediate victim.
2b III. Incompetence. Stupid, unqualified, or unprepared people can be promoted to astonishingly high levels. This is going to sound counter-intuitive, but do their job for them, but don't let them take credit for it. Ensure the work gets done and everybody stays safe. Don't worry about a paper trail because actual incompetence is obvious and people talk. If their incompetence results in harm or high risk situations they will typically be removed before an investigation falls upon their boss.
2c. Peers
2c I. Toxic. People primarily interested in self-serving interests aren't leaders. Address this directly with both them and their boss. Document what you see, but keep it secretly to yourself. If the toxic behavior is bad enough to warrant an investigation it often comes down to paper and good paper will protect you and the toxic person's subordinate.
2c II. General Incompetence. Talk to them and figure out what's going on. Sometimes a life situation can arise that provides serious distractions. Help a buddy out and try to get them on the right track. If they continue to fail, well at least you did all you could to try to fix the problem... right?