The first way is when someone, typically a recruiter, runs a simple Boolean search. These words are logical - phrases one would typically associate with the job at hand - business development, sales management, etc. Nothing too complicated here.
The second scenario where keywords come into play is via a job board. As I've learned from Preptel (see below), job board keywords and the weight they are given is nearly impossible to predict because the software picks them. The other impossible to know aspect is that the words are weighted based on rarity among the pool of candidates, so if a keyword phrase, say business development, for example, was found on 90% of the resumes from candidates applying for the job, the term might be given a weight of 1. But if a keyword phrase, let's say executive sales leader, only appeared on 10% of the applications for that position, it might be given a weight of 5. Those with the most cumulative points appear highest on a keyword-ranked list. Recruiters use this list as a starting point when making keep/toss decisions.
A company for whom I'm a beta tester - www.preptel.com – recently made their product free to job seekers. While it's still a bit buggy, its core functionality works well and does something no other software I've seen can do - identify missing keywords. One puts in their resume, adds the job posting, and an analysis is done to determine which keywords are missing. If the missing keywords are in alignment with your skills, they can be worked in to the resume, boosting your standing in a keyword ranked list exponentially. I encourage you to check out the software and use it in your job search to ensure that your resume is as keyword optimized as possible for each position you apply for.