How does a coffee bean get its smokey flavor?
It's all about the roasting process.  The beans themselves have a much subtler flavor, a bit closer to tea really.

Try tasting a light roast coffee compared to a medium roast or dark roast at your local coffee house.  The differences are readily apparent.  The coffee you describe was most likely a dark roast which generally has a quite smoky and even burnt character.