Is it legal for an American citizen to obtain [foreign] currency and then
exchange those bills for U.S. dollars sometime in the future?
This answer only considers the U.S. law implications, not the legal considerations of the countries issuing the currencies, which usually wouldn't have the practical ability to impose their laws on American citizens who are physically in the U.S. in this situation.
Generally speaking, if you are doing this with your own money, it is legal. If you are doing it with other people's money, you generally have to be registered as a commodities broker.
There are regulations of currency exchanges in many foreign countries, but generally speaking, if it is not for an improper purpose like money laundering, it is fine. A U.S. branch of a foreign exchange bank won't let you do anything that violates U.S. sanctions regimes.
Cash transactions (including both U.S. and non-U.S. currency and certain cash equivalents) worth more than $10,000 U.S. in a year must be reported on an information tax return to the Treasury Department. But this return doesn't have an associated tax, although a high volume of this cash transaction activity may attract an audit.
Of course, your income from your currency transactions is taxable income. Also, if you are doing this for an investment purpose in the U.S., under changes to the tax laws made in 2017, your transaction cost expenses (e.g., separately stated banking fees, safe deposit box charges, money spent on a service to monitor exchange rates in real time, etc.) aren't tax deductible.
Also, most insurance companies won't insure significant amounts of currency on hand against theft or accidental destruction (e.g. in a fire). So, this isn't necessarily the smarted way to do it. Trading in currencies through an account with a currency broker is smarter and won't generate information tax returns.