Money can be made from music in many different ways - not just royalties from songs being played. For instance, concerts, documentaries, TV appearances, merchandise etc. A record company won't just make money from songs being played or sold, and therefore can afford to be flexible with what they negotiate with a singer or songwriter.
But even outside of that, songwriters or singers both have the ability to negotiate what they want into a contract if they are good enough and in demand. As they become bigger artists and renegotiate contracts by extending them with a record company (or jumping ship to another one), they are probably in a strong negotiating position. They are the brand after all, and the music company is not likely to make money without them. I bet Bruce Springsteen's first record contract was worth a lot less than one of his contracts at the peak of his career because of that.
Plus royalties can be (and are set) as percentages - they don't have to be exclusively owned by one party. The record company might take the largest percentage, but the songwriter will take another, the producer another, and possibly even the management company of the artist would take a percentage too. Once you cut that all down, the artist themselves might also get a small percentage.
Like any contract, you have two or more parties that need each other. Record companies might be tougher based on how music markets have changed in the last 20 years and because of large amounts of money being paid for back catalogues, but they will still have an artist they want to sign and will therefore make them an attractive offer based on that, which is likely to include royalties. Otherwise artists will just go to another record company that can offer them what they do want.