Even more important over the short term is the administration’s declared policy of cracking down on unauthorized immigrants with waves of deportations, detentions and incarcerations, a program that will require a vast expansion of federal resources. Financial analysts say this could mean that newly detained immigrants will flow into underused buildings owned by the two companies, filling “idle” space and significantly bolstering profits.

“The deportation crackdown is doing very good things for these companies,” said Terry Dwyer, an analyst with KDP Investment Advisors. “On a personal level, it leaves a sour taste in my mouth, but I guess business is business.”

When the companies’ executives reported earnings in February, it was too early for hard numbers on how the shifts in United States policy were affecting their companies’ bottom lines, but their excitement was evident.

In a conference call with Wall Street analysts on Feb. 22, for example, George C. Zoley, chief executive of the Geo Group, said that when it came to protecting the southern border of the United States, his company was “the largest provider of detention services to the three federal agencies” involved: Immigration and Customs Enforcement, Customs and Border Protection and the Marshals Service.

What the country is seeing, he said, is “really an escalation of capacity need for all three federal agencies as a result of the president’s new executive orders.” Geo, he said, is prepared to help meet those needs.

Mr. Zoley spoke in detail about the probable impact of one change ordered by Mr. Trump, the end of the so-called catch-and-release program. Under that effort, as Mr. Zoley put it, “As people were caught illegally crossing the border, they were held very temporarily and just let go instead of being detained.”

Now that Mr. Trump has ordered that many of those people will no longer be released immediately, Mr. Zoley said, the government needs “detention and informal processing,” a service that will require “several thousands of beds” more.