The two biggest factors are time and the ratio of vanilla(or other flavorant) to spirit, and they go hand in hand.
Let’s start with time:
For infusions, it does not take long to get a good product. You can infuse the flavor you are looking for in anywhere from a couple of hours to a couple of weeks, depending on what you are working with and the final flavor profile you want.
For extracts, on the other hand, the longer the better, to a point. Depending on what you are extracting, you are looking at anywhere from a couple of weeks or months to possibly a year or more for full flavor development. That said, there will always be a tipping point where additional time becomes less critical for flavor development.
In either case, the value of time in developing flavors and achieving your desired profile cannot be understated, and it is why it is always good to check on your infusions and extracts regularly. I generally check infusions every day or two, whereas extracts can be checked once a week or even once a month.
The other key factor, ratios and concentration:
For an infusion, you generally do not need much of the ingredient you are using to flavor your spirit, unless it has a high water content. For something like vanilla, herbs, or even jalapeños, a few pods, sprigs, or peppers per pint is usually plenty.
With extracts, the opposite is true. Since you are aiming for a much more concentrated final product, you will want to significantly increase the ratio of flavoring agent to spirit. For vanilla and herbs, about a 1:10 ratio works well. That means for every ounce of vanilla beans or herbs, you use about 10 ounces of your spirit of choice. For something like peppers, you may want to go closer to a 1:1 or 1:2 ratio.