Each instruction executed on the dapp costs Gas. This Gas is an arbitrarily set number.
Programmers want to keep Gas consumption high enough so that nodes are motivated to pick up their dapps and run them, yet keep them low enough for users to be able to use the dapp.
Setting gas cost is upto the programmers. Its a balancing act of matching supply with demand.
Setting gas price is upto the users. If you set a high gas price, the dapp will run faster.