Those rewards are not free money. They are paid by the merchants who must then increase the prices that you pay.
It's not the merchants that gives the reward. It is the CC issuer. Every time you make a POS transaction the merchant has to pay a small fee. They share the fee with you.
There are many cases the CC issuer and the merchant strike a deal to give you those rewards.
There are many cases the CC issuer has CC branded under the merchant's name - again, part of a deal that should end up with some benefits for you if you use that CC, compared to the rest of the buyers.