Khamr (خمر) means any intoxicating drink. The Qur'an forbids it (5:90), and the Prophet ﷺ said that whatever intoxicates in large amounts is forbidden in small amounts.
Scholars differ on tiny amounts of alcohol used as a carrier in flavourings, or naturally present in foods like bread and fruit juice, which do not intoxicate. See Is food with a little alcohol halal?
Traditional Hanafi definitions limit khamr to the fermented juice of grapes, though they forbid other intoxicating drinks too. The majority view is that khamr covers any drink that intoxicates, and that what intoxicates in large amounts is forbidden in small amounts.
This is why alcohol in drinks is haram. Trace alcohol that occurs naturally, or is used as a carrier in flavourings, is a separate question that scholars treat differently. In the UK, a drink labelled alcohol-free can contain up to 0.05% alcohol, though the government has consulted on changing that limit.
Vanilla extract normally contains alcohol as a solvent, which is why people who avoid trace alcohol use vanilla pods, paste or alcohol-free vanilla.