Generally Publishers, be they publishing journals or books, request that authors transfer all their rights to the publisher before a work is published.
However
When publishing a scholarly work, either a book or a journal article, the reality is that publishers only really need the right of first publication i.e. a period of exclusivity that allows them to produce and disseminate the work without hindrance. This is something that could be achieved via an embargo period negotiated prior to publication.
You are allowed to do this because it is possible for authors to license the specific rights to publishers that are necessary them to publish your book or journal article while retaining other rights making it easier for you, as the author, to reuse and distribute your work on platforms like the CSHL Institutional Repository and PubMed Central.
This is a process known as "unbundling" and can easily be achieved by an author negotiating with any publisher.