Yes, addiction is an adaptation to painful experiences resulting from trauma, as I have explained in my book, https://www.amazon.com/Traumatic-Experiences-Normal-Development-Shubs/dp/0367429187
Trauma may play a part in whether one uses a given substance (possibly as self-medication) or continues to use the substance.
However, there is a wealth of evidence that genetics and epigenetics play a large part in addictions. Genetic vulnerability for becoming addicted has been established in a variety of studies covering a range of substances. It is interesting to note the number of people who report a memorable experience with their fist use of a substance while most individuals do not have such vivid recollections. That means that the substance provided a "kick" or euphoria not experienced by many of us.
Epigenetics is when the use of one substance or other factors alter the gene expression. For example, some studies have found that being addicted to nicotine makes the effect experience by other substances, such as cocaine more profound. In other words, use of some substances man make the probability of becoming addicted to another more likely.
Te bottom line is that there is no singe simple answer for a very complex phenomena. Genetics, trauma, other environmental factors, etc. pose the possibility of a variety of ways a given individual may become addicted to a given substance or substances.