First of all, you can legally substitute an AB1 for an AB1, or and AB2 for an AB2, but not an AB3 for an AB2. If a drug has both AB1 and AB2 codes, it can be substituted for a reference drug that is either AB1 or AB2.
Second, as far as substitution of levothyroxine or anticonvulsants it is not illegal per Federal Law; however, some states do have laws limiting their substituion. These drugs are known as Narrow Therapeutic index drugs, meaning the difference between subtherapeutic doses and toxic doses is very small. Essentially, these are drugs that need to be closely monitored as the slightest change can result in large changes physiologically (e.g. warfarin influencing INR).
As we all know, or will learn, for a drug product to be considered "bioequivalent" it must be the same chemical compound and must meet certain ADME criteria. For drugs to meet those standards of bioequivalence, they need only be within a certain % of say AUC (15% I think), Cmax, and Tmax. For most drugs, a 15% difference in AUC will not make a big enough difference therapeutically, and can be substituted without worry. However, a 15% difference in AUC for say warfarin or levothyroxin can have a potentially major influence over INR or TSH respectively. Hense the reason that changing from Synthroid to levo, Coumadin to warfarin, or Dilantin to phenytoin is not a good practice; even where it is legal.
Hopefully this response will answer some of your questions.