This is quite a sticky subject and can open up quite a few deep and dark rabbit holes, so I am going to stick to the highest level possible. If you haven’t already, I would strongly recommend watching the documentary “Icarus”.
It is up to every sports federation to determine what supplements are legal vs illegal. For example, the UCI has deemed corticosteroids to be illegal, while the NFL does not consider them illegal. The route of administration is also a factor here. The UCI does not ban corticosteroids if they are administered as an epidural injection (which you would get to help treat herniated discs, of which I had had a few).
Things get a bit more complicated when you look at supplements that are illegal in competition, but fine out of competition. A clear example would be alcohol. Just about every sports federation deems alcohol and illegal substance in competition, but all athletes are free to drink at home / when not competing.
WADA, and WADA accredited labs are the ones responsible for creating the generalized “banned” list. At which point all sports federations have the ability to pick and choose which items they deem illegal. A good example is caffeine intake. Caffeine is a proven performance enhancer, but it is also the world’s most widely used drug. For a number of years the NCAA considered caffeine a banned substance, so college players could get a short term ban for having some coffee before a competition. This has since been changed, and to my knowledge, no sporting covering body had a ban on caffeine intake.
Generally, substances will end up on the WADA list if there are studies indicating moderate to severe negative side effects, significant improvements in performance, or ethical violations. Gene doping was banned by WADA (and most sports federations) in the mid-2000s, despite the fact it had yet to be adapted for human use in any (public) research setting.
You even get some countries enforcing specific rules. Despite being fine by WADA and all sports federations, it is illegal for an athlete in Italy or Norway to use an altitude tent.
As I said, there are plenty of rabbit holes to go down, but hopefully, this answered your question!