The pope's has always been to be the steward of Christ on earth. At times this role may also have included a political or more governmental role but the primary role is always to be the leader of the Church on earth
As for kings, well they were to lead their nation/kingdom. Many kings sought some approval or blessing from the pope because it's always been understood that God allows persons to be in power for whatever reason. So some of these people took it a step further and thought their rule was a mandate from heaven.