Hamilton is about halfway between Buffalo and Toronto, and overall about a 2 hour bus ride from Buffalo. You would take either Greyhound or Greyhound Canada (they're different - check both
Greyhound.com | Home and
Greyhound.ca | Home since they have some different trips shown). It looks like it would be about $20-25. It looks like your best bet would be to take the bus from Buffalo to either Grimsby or Burlington, which are 10-20 miles from Hamilton, since Hamilton isn't on the main Greyhound route between Buffalo and Toronto. Grimsby might be closer to the eastern part of Hamilton. Perhaps you could take a local bus from Grimsby or Burlington to where you need to go in Hamilton? Sorry, I'm not knowledgeable on the bus routes around there...
An alternative would be Amtrak train, which you could take from downtown Buffalo (Exchange Street station) to Grimsby or Aldershot (cities close to Hamilton - Amtrak doesn't have a stop in Hamilton either), but that takes longer and costs more (like $50-60). The train name is the Maple Leaf.
Maple Leaf - the Train from Toronto, Canada to New York City through Niagara Falls | Amtrak
(Megabus has no stops between Buffalo and Toronto, so it isn't an option)
To get from Buffalo Airport to its main bus station (the "Metropolitan Transportation Center"), which serves Greyhound, or its downtown train station, you could either take a cab ($$$) or take the city bus. The bus you would need is #24 Genesee, or if you're coming during the day on weekdays, you could take #204 Airport Express. The bus fare is $2 for the #24 or $2.50 for the #204. Here's the schedule for the 24:
http://metro.nfta.com/Routes/ttpdf/24.pdf and for the 204:
http://metro.nfta.com/Routes/ttpdf/204.pdf
Whatever you do, make sure you bring your passport with you for the border. They are super strict about things like that nowadays.