Power can be bestowed upon someone and it can be earned. These aren't mutually exclusive, but the processes of getting to a position of power are certainly different.
If you've ever been in a job where you got a new boss, there can be a lot of emotions around that. If the person is not a stranger, the transition is different than when the new leader comes from outside the organization. There might be a sense of joy when you know them, hesitation when you don't.
While a person who is hired for a position, in most cases, has done the work to demonstrate the necessary competency, it's not the same as earning the relationship with the direct and indirect reports. The path to earning those relationships might be shorter if the credentials and foundational skills of the new leader are aligned with the role and culture. If not, it can be a long haul for people to believe the person in the position of power has expertise and competence in the role.
A person who has expertise rarely has to say so. "I am an expert in X and I know that..." That can be useful in some spaces, but rarely in a team meeting when trying to make a decision. Through one's contributions, people tend to learn who has expertise and then gravitate toward them for feedback on that particular topic.
In my former role, I was referred to as the expert, not ironically (but, in my mind, certainly overstated). The ironic way is the exasperated acquiescence of, "Well, you're the expert!" The way I heard it was in regards to college student behavior where a colleague would say, what I understood to be deferent and with respect, "You're the expert, we'll follow your lead." Being the designated expert on the behavior of humans who still have buffering executive function is daunting. I did appreciate the weight that came with that and took it seriously.
Referent power is similar in the sense that it is earned and usually through unrelated channels. The easiest example is an athlete's support for a product or service. I like Favorite Athlete and I trust what they say in press conferences. If they say using Replenishing Drink is good for competitive athletes, I'll believe it.
Away from hawking a particular product, a leader at work can earn referent power simply by being someone others admire. If people admire a leader, they are more likely to follow the leader's vision. I like Competent Leader and their idea to improve employee engagement sounds good, fits what I know about them, and is something I could get behind. Whereas if Jerkface Boss put out the same idea, a person might like the sound of the idea, but wonder what does Jerkface get out of this or "This seems good, but what am I missing because Jerkface has never promoted an idea that didn't serve Jerkface Boss first and foremost."
Simply put, leaders hold power in many cases because people believe they do. This can be daunting for the scrupulous and intoxicated to those unburdened by morals.
As you seek out leaders to emulate, examine what makes a good leader and how you see those behaviors in action in the wild. Also examine what doesn't feel right and fully understand why.
Chances are very high that most of us take our cues from those with expert or referent power compared to those who have power due to position or leverage.