WASHINGTON—The release of Army Sgt. Bowe Bergdahl after nearly five years in Taliban captivity prompted cheers among U.S. officials Saturday, but amid the applause some on Capitol Hill are questioning the risks and legality of how his freedom was brokered.

Rep. Howard P. "Buck" McKeon (R., Calif.), chairman of the House Armed Services Committee, and Sen. James Inhofe of Oklahoma, the top Republican on the Senate Armed Services Committee, said in a joint statement that they, too, celebrated Sgt. Bergdahl's freedom. But the exchange of five top Taliban detainees from the U.S. military prison at Guantanamo Bay, Cuba, raises risks for all Americans, they said.

"Our joy at Sergeant Bergdahl's release is tempered by the fact that President Obama chose to ignore the law, not to mention sound policy, to achieve it," they said Saturday in a written statement.

"Trading five senior Taliban leaders from detention in Guantanamo Bay for Bergdahl's release may have consequences for the rest of our forces and all Americans" by giving terrorists "a strong incentive to capture Americans."

They also said that President Barack Obama "clearly violated laws which require him to notify Congress thirty days before any transfer of terrorists from Guantanamo Bay."