My chemistry teacher told us that acids taste sour and bases taste bitter. After reading Do acids without hydrogen taste sour? and https://en.wikipedia.org/wiki/Taste#Sourness I learned that sourness in fact is the taste of acidity. But why is it that bases generally taste bitter?
Some bases taste bitter, some do not. Between bitterness and basicity is correlation, not causation.
The strongest bases like hydroxides of alkali metals and alkali earth metals, or alkali metal carbonates, are not bitter.
Near all if not all bitter bases are organic compounds with basic groups containing nitrogen, like aminogroups or heterocyclic nitrogen. They are often potentially poisonous alkaloids, so evolution came with unpleasant sensation for such compounds. The typical example is quite bitter caffeine.
OTOH, not all bitterness is caused by basic compounds. Grapefruits are bitter because of the glycoside naringin, which does not contain nitrogen and is not a base. Glycosides are frequently bitter, regardless of basicity.
Sensory impact is rather a topic for biology, not chemistry.