To make it worse, some drugs have 3 or even 4 names. Take HIV drugs for example. AZT was the very first drug approved for HIV treatment. It is known as AZT (azidothymidine), zidovudine and retrovir.
Now to answer your question. The generic name is often chosen to reflect the underlying chemical structure of the very first drug in the class, but this in not always the case. For AZT, this nomenclature works, since it is a thymidine analog, thus, azido thymidine. However, for other drugs, the generic name is made up, as is the brand name. But, drug companies do try to have the generic name reflect something about how the drug was identified, where it came from or its structure.
Once the first drug is named within a class, any new drug related to that is given a similar generic name. So, within a class of antibiotics knowns as the cephalosporins, there are a number of drugs with similar sounding generic names, but different brand names.
Bottom line, they aren’t trying to mess with you.