WASHINGTON — As the Taliban attempt the precarious shift from insurgent movement to functioning government, Afghanistan is facing the heightened risk of a financial collapse after being propped up for the past two decades by foreign aid that now accounts for nearly half its legal economy.