This is an example of where prescription medications permitted in one country are strictly controlled in another. I believe Xanax and Ambien are classified as Class 4 drugs in the US, but American classifications do not apply elsewhere (which often comes as a surprise to some, I believe). Even carrying US OTC medications containing Codeine or Tramadol, for example, can land you in trouble in countries such as Greece, Egypt, Dubai - even if you're only in transit.
Both Xanax (and its generic Alprazolam) and Ambien (or Zolpidem or Zopiclone) are controlled substances in Thailand. They are legally available only on doctor's prescription, and only from pharmacies with a special license to fill such prescriptions. No pharmacy will sell it to you without a prescription (probably from a Thai medical practitioner). They, and you, will be fined if they sell it to you. Similarly, Valium, Rohypnol, etc., cannot be sold to you without a prescription. They are all classed as narcotic drugs. Thailand has strict regulations about who can take these drugs into Thailand (e.g., people going there fore medical treatment), and how much they can import (30-days supply).
Other countries, such as the UK, Egypt, also control the import of these drugs by travelers. Australia goes as far as requiring medical practitioners to inform the Department of Health when prescribing alprazolam to a patient who requires a prescription for a long period. This must be done for each patient and only one practitioner can prescribe the medication for the patient at any one time. Alprazolam, Zolpidem and Zopiclone are all Category 4 medications in Taiwan and very tightly controlled.
Traveling with "very old prescriptions" is not advised. I don't know if it is a peculiarity of US prescriptions but those issued in other countries often have a use-by date. A standard prescription in the UK is valid for 6 months from the date on the prescription (unless the medicine prescribed contains a controlled medicine). Australian prescriptions last 12 months, I believe. Mine in Taiwan cover 28 days of medication and then expire, though I get three consecutive prescriptions at one time. If you are using very old prescriptions, then generally the amount of medication you bring must be consistent with the amount stated on the prescription.
Part of my job before I retired involved briefing business people being assigned abroad on what to do and what not to do, e.g., business etiquette and so on. It also included advice on healthcare related matters and what medications they could and could not take with them into other countries. Taking medication to help sleep while flying was one of the issues discussed, depending on the length of the flight. For example, use a long-acting medication like Ambien on a short flight is not advisable because you could find yourself too dazed to take care of yourself during an emergency or when you arrive at your destination. If you really want to sleep while flying, melatonin is said to be a better option.
With regard to being "afraid of marijuana smell and dogs," you were probably wise to buy a new suitcase. I know of a case where an American exchange student was stopped at Chubu Centrair International Airport in Japan and detained for three days because a sniffer dog detected the smell of the marijuana cigarette he had smoked before boarding his trans-Pacific flight.