In any field, competency and the ability to do a job is not all it takes to succeed. Assuming that, because you are good at a specified task, you have job security is dangerous. The truth is, even those who are the best at their jobs are at risk of losing them for one reason or another. For anyone fired and wondering why this is so, even though they are competent, there are a few reasons that could explain it. Sometimes, you never know the reasoning. It depends on the situation and the individual, and it requires inside knowledge that some people will never have.
No matter the job, you have to get along with others. While you may have skills above your peers, there is an expectation of friendliness and cooperation amongst the staff. Anyone who creates a hostile or uncomfortable environment is at risk of firing. It does not matter if you are competent at the tasks if you cannot get along with everyone else. It affects the work and satisfaction of those around you while making you look less like a team player.
If you do anything inappropriate or against the rules, your competency may not save you. Sexual harassment, as an example, can get you fired even if you show great work and skills. You put the other employees and the business itself at risk when you act in such a manner.
Disrespecting those above you can cause trouble, too. You might not see some behavior as disrespectful, but they might. Anything from insults to assuming you know more than the boss knows might not go over well with them.
Any of this behavior towards clients is unacceptable. If you disrespect or act inappropriately towards a client or customer, you lose the business money. This could easily cost you your job.
Sometimes, you are not as competent as you think you are. Some people think their skills are greater than they actually are. In this situation, you may not possess the skills or ability to do the job as well as expected. Other times, you might have risen to a level beyond your skills. Maybe, in a lower position, you were competent, but that changes as you climb up the ladder and beyond what you can manage and realistically achieve.
Maybe your competency does not work with a new system. If the business changes the way they carry out certain tasks, and you cannot adapt, you are no longer a valuable asset.
Not all firings are due to your own failings. In fact, you may have done nothing wrong but still lost your job. Economic downturn causes thousands to lose their jobs. The worse the economy is, the higher the risk of losing your job.
Another common reason beyond your control is when management changes and they want to bring in their new team or they feel that your position is no longer necessary. They might prefer their own team, they might want to give friends and family the position, they might want to get someone cheaper, or they might want to remove it entirely.
The boss may not like you. This might seem personal and unprofessional, but it is something that happens. A boss will put his or her own feelings about the employee above anything else, and they may fire you as a result.
Not every firing has a reason. At-will employees can lose their job at any time, for any reason. Personal dislike or professional incompetence, no reason is necessary. You may not have any control and you might not have done anything wrong.