I got my first agent through my lawyer.
I had written a play which he had read and liked and offered to give it to her. She liked it, took me on, never did a single thing and eventually I fired her. (Soon all your readers will be writing in, "How do I get my next agent?")
I had a lawyer already because, in a freak hiring, I had been given a job right out of college at Saturday Night Live and needed someone to review the contract.
It seems like the short answer inevitably has to be contacts. I don’t know anyone who got an agent by just picking a name out of a book and submitting.