First, it is the ingredients. For example, shortbread cookies don't have liquid, while other types do have liquid. This makes them quite different. Also, there might be ingredients you didn't pay much attention to (mono- and diglycerides, for example, which might have been present at the end as an E number only), but they still can change the mouthfeel a lot.
The second thing is the ratio of the ingredients. The same ingredients in a different ratio will work to give you a different texture.
The third thing is the process. Depending on the order of combining the ingredients, and the amount of mixing, and whether you chill them (and when, and for how long) you end up with completely different textures out of the same ingredients. It is like starting with carbon and ending up with graphite, graphene or diamonds, depending on how you do it.
The fourth thing is the baking process. You can change the temperature and time to achieve different final results.
I realize this list is very, very general. But listing all possible results which can be achieved at each step would make this a small book. Each of the four steps gives you a large number of parameters to change, which changes the end result too.