Prague is more expensive because the set of buyers and potential buyers (or consumers) is wealthier which is why the equilibrium market price for many things (like restaurants) is higher. The potential buyers are wealthier because the wages in Prague are higher, often by a factor of two in average, than they are outside Prague; and because the buyers are supplemented with foreign tourists or officials or business people who mostly do their work in Prague.

Wages in Prague are higher because Prague is closer to the veins with money, either in the form of the tourists that want to see one of the most beautiful cities in the world, or in the form of important people of business and politics that have offices or at least meetings in Prague, not so much in the rest of Czechia. All this wealth, sometimes well-deserved wealth, sometimes not, is dripping to all the people who live in Prague.

Let me mention that some things actually are not more expensive in Prague. Supermarket chains etc. are actually often even cheaper in Prague than elsewhere, perhaps because it is easier to move the products from one place to another. A high population density may bring some problems but it also increases effectiveness of many things and makes many things cheaper.