These books are called remainders - excess copies that were printed but never sold. Although the bookstore could return these books to the publisher, the publisher would prefer to get rid of the books, even at a tremendously reduced price. So the publisher sells them to bookstores for next to nothing, provided the bookstore agrees to sell the books at a heavily discounted price. Or the publisher sells them to a remainder wholesaler, who in turn sells them to stores. If the books are returned to the publisher they may be warehoused or, especially if the price of paper is high, recycled.
Trade paperbacks are ones that are usually kept in stock.
Generally, a bookstore gets a discount of about 47 or 48 percent off the cover price. So the publisher receives about 53 percent of the book's retail price, before paying out royalties, and the bookstore keeps the rest. The author's share, or royalty, is roughly 15 percent of the retail price, and the author's agent gets 15 percent of the author's cut. You now have your book, you know where it's from and you know who's getting the money for it.