Can your company fire you for applying to a competitor?
In an at-will jurisdiction, an employer can usually fire you for almost any reason that is not illegal, and applying to a rival is not a protected activity. Whether they can stop you from taking the job is a different question entirely.
Before anything else: I am not a lawyer, this is not legal advice, and employment law varies enormously by country and state. If your job or real money is on the line, talk to an employment lawyer where you live. What follows is the plain-English shape of the problem so you know what you are dealing with.
The short answer
In an at-will employment jurisdiction, an employer can generally fire you for nearly any reason that is not specifically illegal. Applying to a competitor is not, in most places, a legally protected activity. Job hunting does not get the protection that, say, reporting safety violations does.
So yes. In a lot of places, they can.
Whether that is decent behavior is a different conversation, and the answer there is usually no. But legal and decent are not the same category, and confusing them is how people end up surprised.
Two questions people mash together
This is where most of the confusion lives, so separate them.
Can they fire me for applying? That is an employment-at-will question. Usually yes, in at-will jurisdictions.
Can they stop me from taking the job? That is a non-compete question, and it is a completely different animal. It depends on what you signed, where you live, and how broad the agreement is.
You can be in a situation where your employer can fire you for applying but has no real ability to stop you from joining the competitor. You can also be in the reverse. These are separate legal mechanisms and conflating them will lead you to the wrong conclusion.
Non-competes are less bulletproof than they look
The agreement you signed on your first day, the one you did not read, is probably broader than a court would actually enforce.
Enforceability varies wildly by jurisdiction. Some places enforce them fairly readily. Others treat them with deep skepticism or restrict them heavily, particularly for lower-paid workers. And even where they are enforceable, courts frequently narrow agreements that are drafted too broadly, because a clause that prevents you from working in your entire industry anywhere on earth for five years is not a reasonable restriction, it is a hostage note.
None of which means yours is unenforceable. It means you cannot tell by reading it and feeling scared. That is what the lawyer is for.
The practical reality
Most of the time this never becomes a legal problem, because most employers do not want the fight. Enforcing a non-compete is expensive, public, and makes you look like a company people should not join.
What usually happens instead is quieter and more annoying. You get passed over. The reference call goes cold. You get managed out over three months for reasons that have nothing to do with the real reason.
So the tactical advice, which is not legal advice: be discreet while you are looking. Do not use the work laptop. Do not tell the colleague who tells everyone. And read your contract now, before you need to, rather than the night you get the offer.
And if the stakes are real, pay a lawyer for an hour. It is the cheapest hour you will spend on your career.