When it comes to the chemistry of flavor, our foods and drinks are much more connected than you'd think. Any experienced beer taster can pick out the banana notes in some Belgian beers and hefeweizens. What about when a beer reminds you of chocolate, grapefruit, or toasted bread? Well, sometimes that's because it actually is that. When you strip a complicated flavor down to its prominent elements, you'll find that many of them are identical to those found in other foods.
Lets start with some common hops. Some of the American varieties that we all know and love, like Centennial, Cascade, and Amarillo, are commonly described as being citrus-y. Add them to the end of a boil and you'll get the aromatic oils and other compounds that provide the bulk of the flavor and aroma that hops contribute. Much of the flavor from hops comes from terpene compounds, which are very common oils found in many different plants. For example, a particularly citrus-y hop may have high levels of limonene or citral, which are major flavor components of oranges and other citrus fruits.
There are many different types of terpenes, each of which can contribute different and very recognizable flavors. Combined into a cocktail of many different terpene and other compounds, they can create the complex impression that we immediately understand as "orange". Hops are particularly rich in several terpenes, including myrcene, which is also prominent in mangoes (Citra hops, anyone?) and cannabis (Cluster and Nugget to my nose). There are also large amounts of humulene (cannabis again), beta-Pinene (found in coniferous tree resin and contributing piney aromas as in Simcoe or Chinook, and also a component of basil, roses, and dill), and Caryopheyllene, which is found in, ahem, cannabis, as well as cloves, black pepper, and oregano.
How about beers that taste like chocolate or coffee, or even the malts that are named after these two foods? The roasting of dark malts, coffee, and chocolate is quite similar. All three are seeds of plants which are dry roasted using high heat. The dry heat causes the breakdown of starches into simpler sugars and then the caramelization of those sugars. The other process at work in roasting is known as the Maillard reaction, which is slightly different, but also includes high temperatures and sugars, and contributes to the characteristic flavors of toast and browned meats. The Maillard reaction and caramelization produce a range of different chemical compounds that result in the "roasted" flavors that we all know. Particular malts, roasted using particular schedules, will have characteristics similar to those found in the end products of coffee and chocolate.
And finally, those banana notes in your hefeweizen. Many of the fruity yeast-derived flavors come from esters, which is a group of compounds that results from a reaction between higher alcohols and certain acids. In this case, the characteristic banana note comes mainly from isoamyl acetate, which forms from acetic acid and isoamyl alcohol. This ester is produced naturally by bananas, and also by many of the German hefeweizen yeasts. There are numerous other esters that provide a variety of fruit and other notes both in beer and in the wild.
So, the next time your beer reminds you of toasted bread, strawberries, or tangerines, just think to yourself that it may be more than just a resemblance. It could be that you really are tasting the exact same compound or set of compounds in your beer that you do in these other food items.