@AlBUNDY4TDS is correct. Prices in the city reflect the simple principal of supply and demand.
People choose the urban setting because it’s close to amenities they enjoy, from grocery stores to bars. They don’t need a 20 minute drive to go buy toilet paper.
Urban space is naturally limited, so when existing housing supply is used up, and it’s too difficult to build new supply, the price goes up.
That 1,200 square foot condo might be more expensive than the equally-sized home in the sticks, but there is a big difference in quality of life.