Of course the cost goes up. Densification does not lead to lower prices, because it
increases wealth. People in denser areas make more money, because businesses in denser areas are more productive, because density is efficient and causes people to be more productive.
This is a good thing.
Affordability is not cost. The problem that we have now is that supply of housing is artificially constrained by bad policy, which allows some groups to capture the surplus. It is broadly not a coincidence that the groups that capture the surplus are the very same that set policy.
It seems to me that "some forms of densification are allowed pretty much everywhere" is doing a lot of work for you. Can you elaborate? How easy is it to build an apartment building "anywhere?" [1] is an example of what I mean, but you can google "housing supply shortage USA" if you want general statistics. The conclusion is pretty much unanimous: it is immensely difficult to build anything, anywhere, which has caused a massive shortage in the supply of housing. Again: density, solution.
If we allow buildings to be built, a developer will gladly come in and build buildings. Someone building a house for someone else to live in is, in general, a very good thing. Everyone participating in this conversation lives in a house that someone else built for them and made a profit in so doing, and it's a good thing, because that allows us to work and create value.
[1] https://twitter.com/cafedujord/status/1692713611683066073