No. The immigration applicant is generally not entitled to his or her attorney fees in this situation, even though the government is violating one of its own laws.
The Black Letter Law Question
The Right To Fees Depends On The Legal Theory Advanced
A consistent answer doesn't exist at the level of generality of the title question.
Some of the statutes that relate to a violation of the law by a government official include an attorney fees remedy to a prevailing plaintiff, while others do not.
Violations of constitutional rights enforced under 42 U.S.C. § 1983 entitle a prevailing plaintiff to an attorney fees award. But the immigration law is a statutory requirement not a constitutional one and there is no generalized constitutional right to have the U.S. government comply with every provision of every enacted statute. Indeed, the general rule is that enforcement of statutory rights against private individuals is discretionary and non-justiciable.
A writ of mandamus filed to compel the federal government to take action as it is required to do under the immigration laws would usually arise under the All Writs Act, 28 U.S.C. § 1651, which does not generally entitle the prevailing plaintiff to attorneys' fees, and that would probably be the case in an All Writs Act petition for a writ of mandamus filed in relation to the timely processing of an immigration application. But the All Writs Act is basically a statutory touchstone through which the door is opened to the entire pre-Revolutionary War English common law of writ practice as modified in a common law manner through case law by the American federal courts, and there are probably some exceptions in fact patterns beyond the scope of the question.
This said, I am not an expert in immigration law and it is possible that there are administrative law remedies under either the federal Administrative Procedures Act (APA) or the Immigration and Nationality Act (INA) which might provide a different solution to the same problem.
Article III Court Litigation Is The Rare Exception In Immigration Cases
Keep in mind that most immigration law matters are in the exclusive original jurisdiction of the immigration courts, which are not Article III courts, and are instead staffed by administrative law judges operating according to immigration court procedures, which must then be appealed to the Board of Immigration Appeals, and only after those remedies are exhausted may most immigration cases be brought before an Article III court which in that case is the U.S. Court of Appeals for the circuit in which the case arose within the immigration court system. And, appellate review of BIA decisions is quite limited.
Perhaps someone more familiar with the federal APA and INA would know if there is any right to attorneys' fees under those acts, although I suspect that the answer is that there is not.
Indeed, the fact that Article III litigation is such a rare exception to the general rule is one of the reasons that this problem has not been viewed as a crisis that is critical to fix. It is easier to find alternative funding to litigate cases that come up only dozens of times a year than it is to do so for issues in cases that are routine and pervasive.
Exceptions Apply Where There Is Wrongful Government Litigation Conduct
Also, while attorney fees are not recoverable as a matter of course in actions arising under the All Writs Act where there is not a common law right to attorney fees in a particular fact pattern, attorney fee awards may still be entered in an action under the All Writs Act, or under any other cause of action in federal court, as a sanction for wrongful litigation conduct.
There are three kinds of sanctions for wrongful litigation conduct that commonly arise:
Rule 11 If a party files a legal document in a federal court case which is frivolous (i.e. lacks any colorable legal basis), groundless (i.e. lacks any factual basis), or vexatious (i.e. is made for the purposes of harassing a party or delaying the case for no legitimate purpose even if it is not otherwise frivolous or groundless), then an attorney fees award may be made as a sanction proportionate to the fees incurred as a result of the wrongful litigation conduct under Federal Rule of Civil Procedure 11.
Discovery Sanctions If a party fails to obey the rules governing pre-trial disclosure of information in "discovery" forcing the other party to enforce those obligations in motion practice prior to trial, one of the remedies that the court may (and often does) provide for this wrongful conduct is to award attorney fees to the party that requested the information and did not receive the response that party was entitled to under Federal Rule of Civil Procedure 37.
Contempt of Court If a party or someone else with knowledge of the court order and some relationship to a party fails to obey a court order, or if someone who is present in the courtroom engages in conduct disrespectful to the court in the court's actual presence, party who engaged in this misconduct may be held in contempt of court. Contempt of court may be criminal, simply punishing the wrongdoer for misconduct in the same way that one might for a misdemeanor violation, or civil, imposing incarceration or fines or other remedies until the wrongdoer complies with a court order. When someone is held in contempt of court, the sanction for doing so frequently involves an award of attorneys fees incurred as a result of the wrongful action by a party to the case against the wrongdoer.
Of these three options, the third, contempt of court, has the most bite as a practical matter. If a judge orders the immigration agency to meet a deadline by a certain time and it fails to do so, which isn't an uncommon result when it has already failed to do so despite receiving formal complaints about the delays, it is very likely that the sanction for failing to meet the court ordered deadline to comply will result in an attorney fees sanction against the government.
Does This Rule Encourage Misbehavior?
what would prevent the government from always abusing its power? It
may decide to process applications as slow as possible, and only
process an application in a timely manner if a lawsuit is filed
against the government (at the expense of the applicant); but without
any further financial consequences to the government.
Sometimes Government Officials Do The Right Thing Because It's Their Job
In any political and legal system, we have to count on some of the key actors to follow the law not because there are consequences for not following the law, but because their job is to uphold the law.
For example, we trust judges and juries to try and rule in accordance with the facts presented to them and the relevant law in the cases they decide in court, even though both judges and juries have absolute immunity from liability for their official judicial acts.
The President, and every single other federal government official, federal judge and federal administrative law judge, is likewise sworn to uphold the constitution of the United States, and the President and everyone else in the executive branch acting with authority delegated to them from the President's Executive Branch power has a duty to "faithfully execute the laws" of the United States.
Presidential elections represent (theoretically anyway) the judgment of the American people concerning who is most able to do that job properly and to make good choices about how to exercise discretion in doing so.
Also, as a practical matter, many snarls in the immigration process are handled by members of Congress in their constituent service role or through the passage of private laws, rather than by attorneys for the applicants in the Article III court, in part precisely because individual litigants can rarely afford to pay lawyers to do that. Almost every Senator and members of the House of Representatives (539 in all including non-voting delegates who still get staff), where I worked as an intern for a while, has a staff member who devotes perhaps 1/4 to 1/2 FTE to resolving cases like this one.
Sometimes Delays Are Unavoidable And Not Due To Official Misconduct
The wrongfulness of the delay is also mitigated by the fact that often delays are not due to any bad faith conduct on behalf of the federal government officials involved. It is not infrequently the case that it is impossible for federal government officials to do the job that Congress have given them a mandate to carry out, by the deadlines that Congress has set forth, with the funds that Congress has appropriated to them to get the job done. This is true not just in the immigration law context, but in all sorts of circumstances.
The Political System's Design Naturally Disfavors Immigrants
Of course, politicians and government officials often don't do everything that they are supposed to do for reasons that aren't noble or blameless. The administration in place for the last four years as of the time that this answer is written specifically campaigned on a platform of radically reducing legal immigration and largely succeeded in doing so, even though it lost many particular legal battles on that front. This wouldn't be the first time that this has happened. Immigrants, by definition, are made up of a class of people who can't vote in Presidential or Congressional elections and, as the median voter theorem would predict, their interests as non-voters fall to the bottom of the political priorities.
The U.S. Legal System Is Applying Rules Designed For Different Contexts
The other reason that this happens is that it evolved that way.
There are a lot of good policy reasons (beyond the scope of this answer) for the American Rule that each side bears their own attorney fees in lawsuits between private parties. In a nutshell, it encourages people not to litigate minor disputes and encourages settlements that reduce the deadweight loss of transaction costs associated with litigation in lawsuits where there are substantial amounts in controversy. There are good arguments for the opposite rule as well, which is why there are many exceptions to it and why the English legal system, post-1789, ultimately ended up changing its default fee shifting rule.
But when that rule was put in place, "public law" (i.e. lawsuits between the government and private individuals and between governments) was largely outside the jurisdiction of the common law courts that are the ancestors of the modern U.S. court system. The general rule was that you couldn't sue the government or government officials at all, and there were few exceptions and the scope of government regulation in people's lives was much smaller, although that was starting to change.
Other Countries Adopt The Rule You Propose
In contrast, in French law, under the First Republic, sovereign immunity from its citizens (that survived in England) was abolished, and the Republic established a separate legal system for handling public law disputes, under the supervision of the French Council of State, that has endured through the present.
In the French system, copied in principle (although not every administrative detail) by essentially all other countries with a civil law legal system, once you file a public law complaint (on a form you can purchase at your neighborhood convenience store), the Council of State assigns one public law lawyer (basically a senior civil servant and not a member of the same legal professions as private law lawyers and notaries and prosecutors and judges) to represent the government in your case, and assigns another one from the same pool of government lawyers to represent its citizens in the case, in a manner similar to how barristers are assigned to serious criminal cases on a case by case basis in the British criminal justice system.
There is a lot to be said for the civil law approach. Historically, it has led to government bureaucracies that are better run and treat citizens more fairly and with less corruption, relative to U.S. style systems, which is an important reason why state owned enterprises are much more popular in countries with civil law systems than in countries without them. But that simply isn't the path that U.S. law has taken, even though there are good arguments that the U.S. system is more vulnerable to being unfair.
Various Workarounds And Limitations Prevent Worst Case Scenarios
Still, because government officials do try to follow the law as best they can most of the time (especially career civil servants who implement the political appointee's policies), and because really outrageous litigation conduct by government lawyers who take unreasonable positions in public law litigation can result in judicial sanctions, the system still does provide some means for relief when the government violates the law.
Finally, the fact that attorney fees aren't shifted in these cases doesn't mean that these cases aren't litigated. In some cases, the individual or their sponsor can afford to litigate the issue. In some cases, immigration attorneys litigate the issue pro bono (i.e. without charge to the client) because the issue has importance to their ability to deliver results to all their other clients or as a form of charitable giving and, in some cases, local governments fund this litigation on behalf of their non-citizen residents or non-profit advocacy groups fund this kind of litigation from private donations.
For example, the City of Denver is among those local governments that has established a fund to help pay lawyers to litigate immigration issues on behalf of its residents to address the financial barriers those residents face to enforcing their legal rights under federal immigration laws.
So, in an example of the Coase Theorem of economics, even when the formal legal arrangements and rules of a system are non-optimal, a free market economy tends to find workarounds that reallocate unfair burdens in a way that is sufficient to make the system as a whole function better.