Making coffe at home is always cheaper, that why it's attractive to sell coffee, I'm guessing that a coffee place buys their coffe cheaper than you, but they pay rent, staff, other bills and take the risk of owning a business.
And the price of coffe has high correlation with it's availability. No one wants to walk a mile outside of the city center to buy a coffe on their way to work even if it's 80% price difference, and that is what allowed them to sell cheap coffee for higher prices. But there's more to it than that, you have different variants of coffee, some like to pay a lite premium to get a more exclusive one etc etc, there is probably a whole science about coffee pricing.
Not that often, but mostly to socialize with friends, 8 bucks for coffee is to much, I avoid those places and go to places where it is about 2€ and spend some on a piece of cake.
But yeah, some people are not that responsible with their money and are willing to buy a coffee for 8$.