The Budapest Public Transportation Center (BKK) operates a Customer Service Point on the Liszt Ferenc International Airport. You can purchase tickets for public transportation in cash or by, credit card.
There are vending machines all around the city center and at the metro stations.
It’s possible to buy tickets directly from the driver on the vehicles but obviously, it’s more expensive and only Hungarian Forints are accepted. The best way is to buy tickets in advance.