Short answer: supply and demand
Slightly longer answer: The price of a certain cryptocurrency on a certain exchange is set by the latest buy or sell offer that has been executed on an exchange. As for the prices you see on CoinMarketCap, it's the average price of that certain asset on all the listed exchanges.