My idea of a literary agent, I think, came straight out of American movies about writers. In those, the agent is some guy with a cigar and a New York phone number who calls you up and says, "Darling, I read your manuscript, it's genius." Then comes a lunch at a fancy restaurant, a contract with a major publisher, and a bestseller.
Reality turned out to be considerably more modest.
I didn't start looking for an agent right away. I sent my first book to publishers myself; the second, a year later, also myself. I started considering an agent as an additional option. I thought: if I had an agent, it would be easier to get through doors that were otherwise closed. I found a few names — through professional communities, social media. I wrote to them.
A couple of agents never wrote back. One did respond, but turned me down because of my book's genre.
A literary agent is a business too. They take a commission on sales, which means they're interested in books that will actually sell. And for a book to sell, you need either a name or a hot genre. I had neither. I was a first-time author with no audience, and a book that's hard to slot into an obvious niche. That's a high-risk position for an agent to take on — and absolutely no reason for one to bother taking my case.
If you want to get published, use every path at once. Submit yourself. Look for an agent. Publish on self-publishing platforms. Don't bet everything on one road — bet on the destination. There can be more than one road that gets you there.