An interesting approach we used to have was where rather than adjoining gardens at the back, we'd put an path down the back of the townhouses between the gardens, with a door into each garden, so you could easily walk/cycle and, if needed, get equipment into your back garden. Apparently we stopped doing that because those alleys turned into major crime and antisocial behaviour hot spots, and people stopped buying houses with alley access due to people constantly jumping your fence and nicking anything in your garden that wasn't tied down.
Where I grew up was like a townhouse/semi-detached hybrid - the upper two floors were terraced, but at ground level there was a car garage that connected the street and back garden. A lot of people don't like that design because it's associated with council homes (mine was a council home), but I actually thought it was a best of both worlds.
In general, though, density doesn't mean that you can't have yards. Do you need a front yard, back yard, and two side yards to set up a wood fired pizza oven, grow potatoes, and build things? Nope. Just a backyard could be fine. So you could share an exterior wall with your neighbors, stick your front door right up against the street, and do all the same things as a freestanding house but at lower cost and higher density. If townhouses were more of a thing, you could have everything you want, AND not have to drive. The only problem is zoning laws.