Public transport brings you only so far. It works for some places; for example, reaching Jasper National Park (Alberta, Canada) by train or bus is easy. Death Valley National Park (California, USA), not so much.
Where public transport ends, several alternatives exist:
Hitchhiking
Culture about hitch-hiking varies widely between countries. In the USA, the media-industrial complex has taught people to fear each other, leading to fearmongering and a consideration of hitch-hiking as extremely dangerous. I think it's actually banned in US national parks. On the other hand, it was explicitly recommended to me in Jasper National Park in Canada. The experience was not great. It took me five hours on the Icefields Parkway before a friendly singer-songwriter picked me up and brought me back to Jasper (I had not planned to hitch-hike from there, but weather forced me out of my hike early). I have successfully hitch-hiked from trailheads back to town in Canada, Iceland, Norway, Poland, France, and Sweden. It's easier if you arrive at a car park, where you can address fellow hikers directly, if there are any.
Taxi
I've taken taxis to and from trailheads from the nearest public transportation. I've done this in Portugal, Spain, Switzerland, Norway, Iceland, Russia, and Canada. It costs a bit, of course, but if you are sharing with a group then the costs are manageable. Expect to pay a premium to go on a rough mountain road (although I paid the same for 120 km / 6 hours in a 6 WD including major river fords in Russia, as I did for 40 km on a major highway in Norway).

Getting to the trailhead in Yugyd Va National Park by Russian mountain taxi, fording the Ко́жим (Kozhim) river in a TREKOL, 3 September 2019.

View from inside. Note that we're in a car, not in a boat.
Bicycle
I've used my bicycle to get to and from trailheads, bringing all my hiking and camping gear on my trekking bike. If you can bring your bicycle on public transportation, you don't need to bike all the way from home, saving time for remote destinations. I'm considering cycling to Kverkfjöll and Nýidalur in Iceland and start hiking from there; those destinations are more than 120 km from the nearest bus stop, along rough tracks featuring unabridged river crossings; getting there by mountain taxi is out of my budget (there used to be a mountain bus, but not any more).