It is possible to find yourself a publishing contract without a literary agent. Although many of the bigger publishers won’t consider unagented submissions, there are plenty of excellent small-to-medium publishers who will; and some writers have very little chance of finding representation because of the form in which they choose to write.
If you write only poetry or short stories then you’re probably going to struggle to find yourself a literary agent who is willing to represent you—and you probably won’t want the ones who volunteer for the job. In any case, your writing probably doesn’t need a literary agent: most short stories and poems are sold to periodicals by their authors, and anthologies are usually published only with a big-time author’s name on the cover or only by the smaller independent presses who accept unagented works anyway.
If you write niche non-fiction, like local history books, which have a small potential market then again, you’re unlikely to find an agent and will probably do better approaching independent publishers yourself, or to consider self-publishing, which is usually a good choice for niche books with an easily-identifiable, easily-reached market.