It all happens during the roasting stage! As the coffee beans are roasted, their color changes from green to yellow and then to light brown or copper/red.
Finally, as they turn dark brown, the desired flavor is achieved. Coffee that has been roasted for longer times will be darker in color and have stronger flavor than lightly roasted coffee.
Light roast coffee usually has a sweeter, more mild taste than dark roast. Light-roasted or 'light' coffees are generally the most popular as they are considered to have less acidity and be "smoother" in flavor.
Dark roast is thicker in body but not heavier tasting than light roast. Darker roasted beans are often used for brewed coffee, because they have been roasted longer which brings out their flavor characteristics.
Some people prefer dark roast as it can be perceived as richer or bolder, although this does not hold true across the board (which is where this question stems).
The term "espresso roast" simply refers to any kind of roast level that is suitable for espresso brewing; other terms like 'dark' or 'mild' are too vague, almost meaningless to describe for espresso.
The lighter roasts tend to be more acidic and can taste sour or bitter if not prepared well. Lighter roasted beans are commonly referred to as "City Roast".
Darker roasted beans may taste more bitter and have a stronger, more intense flavor. When it comes to espresso, dark roasts are generally used as they hold up better during the brewing process.
In general, light roasted coffee is milder in taste than dark roast coffee. However, contrary to popular belief, both of them contain the same amount of caffeine. Roasting coffee has no effect on its caffeine content.
The longer a coffee bean is roasted the more flavor it infuses into the water when brewing. This releases a stronger aroma and flavor from the coffee, which has been described as "dark."
Darker roasted beans are often used in espresso machines for this reason. It does not necessarily mean that darker roast contains more caffeine than light roast; they both contain the same amount of caffeine.
Choosing between the two is definitely a matter of personal preference although in my experience I would recommend a lighter roast for a drip coffee maker and a dark roast for brewing in an espresso machine.
Let me know if you have more questions!