We just had an emergency last year and I went straight to FLL airport needed a flight to NY and to United and they would not sell to me at the counter. I had to call book On the phone from the parking lot, scramble through my iPhone and see what was available and I ended up on a standby for a later flight that didn't happen and got out next day.
You most definitely can book a flight very close to departure. There is no security requirement that the US gov't applies to advance purchase or check-in to domestic flights. Many airlines have their own rules, but they are typically along the lines of you must purchase the ticket at least 30 minutes prior to departure, and check in at least 15 minutes prior (longer if you have checked bags). The main computer check of passengers is done when the passenger checks in and the boarding pass is issued.
For international flights, airlines must turn in their passenger manifest to TSA at least 60 minutes prior to departure, so all passengers must be checked in by that time. Some airlines require ticketing 2 hours before int'l flights. But there's nothing like a 24-hour or longer restriction on airline ticket purchase for security reasons, although a last-minute purchase combined with other factors may get your boarding pass tagged for extra screening at the security checkpoint.
What you describe above was a situation where there were no seats. You said as much yourself: you booked a flight (probably for the next day), were put on the standby list for that evening's flight, but didn't clear. That in of itself tells us that the flight was full. That's why you couldn't buy a confirmed ticket for the same day, not because of any security concern. There are tons of businesspeople that buy new same-day tickets all the time.
No other airlines had flights and it was an emergency for my dad who ended up having bypass surgery. While they did work with me on the phone agent was specific that because it was an emergency they tried to put me on standby but if it was leisure I couldn't just walk up and buy a ticket without 24 hour notice they don't do that at the counter anymore.
I'm not sure exactly what went on there. It may be a combination of agent mistake, a lack of communication, or loose use of terms. What you can't do is "buy a standby ticket for a discount" as a walk-up passenger. That hasn't existed for decades. You have to have an issued ticket with a confirmed seat on
some flight before you can try to standby for another. There's no such thing as a last-minute standby discount. Any discount they have for last-minute travel is offered as a standard confirmed ticket through the normal channels.
Now, it's true that most people don't buy tickets at the airport ticket counter under any circumstances, and they may not be very well set up to handle it. United in fact is taking away the cash drawers at many airports and takes credit or debit cards only, and has a machine that you can put cash in and buy an instant debit card if you need one. And, there's no particular reason to do it at the ticket counter, even if you are at the airport. You might as well just call from a payphone, or use the smartphone application to buy a ticket. But if you really want to, the ticket counter will handle it, even same day, assuming there are any tickets to sell.
And I can't imagine that traveling International could be that easy. If it is then it does raise a valid security concern.
International is another issue. You need to be checked in at least 60 minutes prior, and probably ticket an hour before that. But same day is certainly possible. For flights inbound to the US, if you are not a US citizen and don't require a visa to enter the US, then you need an ESTA, which is like an electronic pre-check of your passport. They say you should apply for one at least 48 hours prior to travel, but many/most applications are approved online instantly and the 48-hour advice is for the cases where someone must review the application manually. But once you have the ESTA, it's good for 2 years, so you could board an int'l flight to the US booked just a couple of hours in advance.