Breed obviously plays a big role in all this too. My youngest, Sage, is a cattle/collie mix and when I put a backpack on her, she just falls in line. I barely even had to train her. Sometimes I try to get her to hike in front of me so I can get pics of her and she just stops when I stop. Meanwhile her hiking buddy Mya is a pointer mix and her desire to roam is incredible. She just goes back and forth with her nose to the ground non-stop. Next thing you know she's like 100 yards away half way up a cliff. She doesn't take off or anything, she's just obsessed with smelling what's out there.
My oldest dog Nikita is an Akita/Pit mix and she was kind of in between. She'd hike with me, but she was really gamey and aggressive to wildlife in her prime. And sometimes she'd take off for like half an hour. Her breed is meant to hunt bears, so when she saw a big animal, it was on. Moose, elk, deer, etc. were all fair game in her mind and it was hard to control in her younger years. She is the reason I started forcing the issue of having her walk behind me. It takes some work at first, but they get used to it and I think it actually helps in a lot of other ways as they begin to see you as more of a pack leader. And it makes hiking with them so much more pleasant not having to worry about them getting to everything and everyone before you do.