Consideration is not (necessarily) money
While the most common type of contract is the supply of goods and services (as consideration) on one side in return for the payment of money (as consideration) on the other it doesn't have to be that way. A promise to do or refrain from doing anything1 is good consideration. A licence contains both.
The licensor promises not to sue the licensee for copyright (say) infringement in return for the licensee promising to do and not do the things in the terms. Consideration is provided on both sides.
There is a mistaken belief that a commercial2 licence is somehow different from a contract - a licence is a contract. If a person wants to give something away - they have to give it away. A gift with conditions subsequent attached is not a gift - requiring someone to only use your "gift" in accordance with some rules makes it not a gift.
1 Subject to the usual restraints: illegal acts are not good consideration, things already required by law are not good consideration etc.
2 Governments also issue licences - to drive, to operate a business etc. - these are not the same as commercial licences and are not contracts.