We made that particular mistake already. You don't need to repeat it.
My home city is Mumbai (technically, the suburban city of Thane, north of Mumbai) one of the most dense large cities in the world.
Public transportation in Mumbai, in terms of frequency, capacity, reliability, and cost is already better than any American city (I'm counting NYC in that). It could definitely be better; for instance the city is served by standard gauge trains but the metro railway (whatever gauge a subway is) that goes underground is still under construction.
Despite all that, and despite the fact that the tallest building in the city is a mere 88 stories[1] the infrastructure is straining under the pressure every day. All the good jobs (government, tech, banking) are concentrated in just one or two parts of the city (South Mumbai and the Andheri-Bandra-Dadar triangle, maybe Powai; my geography might be a bit outdated because I haven't lived there for 8 years). And real estate in those places is astronomically expensive[2] (here's a non-luxury 3-bed apartment for USD 1.3m in South Mumbai). That means everyone whose isn't living with parents who bought decades ago in those places has 3-hour round trip commutes every day (I was one of those people).
Building taller wouldn't densify the city because rich people will likely buy that new housing and they have smaller families on average. Improving public transportation won't change laws of distance and traffic - like I said it's already quite good. It would be better for people in North Mumbai if there were more jobs closer to them so they wouldn't have to commute so far every day.
Suburban, car-driven, sprawl is not ideal for city growth, but neither is the concentration of jobs in one place.
1. https://en.wikipedia.org/wiki/List_of_tallest_buildings_in_M...
2. https://www.99acres.com/3-bhk-bedroom-apartment-flat-for-sal...
I grew up in a Suburb in Colorado where the only buildings for miles were other houses. It was impossible to walk to the grocery store or any other amenity. It's extremely isolating, and a hostile and depressing living experience in my experience
Now I live in a small town and boy do I love it! Since it's a small town there's not really any huge roads and very little traffic. The streets beyond the major thru fares are quiet and the neighbors are friendly. If I'm bored and feeling restless I can walk to the park (half mile, maybe), the local watering hole (2 blocks), the coffee shop (1 block), or even the convenience store (about a quarter mile). I mean, just getting up and taking a short walk to the convenience store seems to be really beneficial to my mental health for some reason, yet driving there does the opposite.
This has been done around the world for nearly a century, it's literally a solved problem but there is a distinct set of politicians in the US that don't want to spend any money for the public goods and would rather give the money out as corporate welfare.