[I stand corrected.]
The US, in the wake of a globe-spanning war that saw widespread use of all kinds of volatile chemicals, a massive governmental apparatus that sprang up to fight that war and a general reputation for competence, failed to foresee the Texas disaster. There was no hope that Lebanon, with its mishmash of literally warring tribes, ethnicities and religions, could have foreseen this. Everyone’s too consumed in the day-to-day business of trying not to be stomped by the various protection rackets at work there for anyone to be thinking about the big picture (i.e. things like chemicals, the appropriate storage facilities and environment and a routine inspection regime).
(Most modern explosives have this pattern, an oxidizer and a reducer in the same molecule.) Ammonium nitrate, NH4NO3, "wants" to be N2 (elemental nitrogen) + H2O + O2 (oxygen). When it gets its "wish," it releases a nice chunk of energy quickly (i.e., it goes "boom").
Because it has "extra" oxygen, you can mix a fuel with it (diesel fuel, or basically anything that burns and can be finely divided and mixed) and get a bigger boom. That's why ANFO -- ammonium nitrate and fuel oil (#2 diesel) -- gives a bigger "boom" than plain ammonium nitrate. Diesel is obviously cheap and easy to get, so people doing blasting with ammonium nitrate (e.g., miners) always use ANFO instead of plain AN.
Ammonium perchlorate is the same deal; oxidizer and fuel in the same molecule. Ammonium perchlorate, with difficulty, can be persuaded to burn very rapidly, rather than explode, with the added fuels of synthetic rubber and powdered aluminum. And that's where you get solid rocket boosters like the shuttle used. It can also blow up if you don't treat it nicely (cf PEPCON explosion).
Saltpeter (potassium or sodium nitrate) has the oxidizer but lacks the fuel -- the potassium or sodium is already in a "happy" oxidation state and just goes along for the ride. It won't blow up by itself, but will decompose if you get it hot enough. If you mix it with a fuel (e.g., powdered charcoal and a little sulfur), the resulting mixture can be explosive, which is how black powder came to be.