Who pays the salary cap?

I mean I get that teams have to pay for going over the apron but who actually pays the year to year salary cap? Every team has like 140 million is cap space who pays that money the NBA or the owner of teams? I know there a rule that where a team has to get rid of like 90% of their cap during free agency and ngl I was just thinking and this popped in my head lol