What are the general benefits a medieval state could get if their Cardinal is elected as Pope? Could the king of that state persuade the Pope to act in their favour? Or would the Pope be actively seeking ways to put his homeland in a better position?
I'd expect it to depend a great deal on the personal connections between the Pope and the King and other notables from the Pope's original home country. Kings often had quite a bit of influence over the selection of Bishops, high church officials often doubled as high officials (e.g. Cardinal Wolsey, who was Chancellor for about a third of Henry VIII's reign), and bishops and cardinals were sometimes royal relations themselves.
I see. But what if a Cardinal of Scotland makes it to the throne of St Peter? Would he impede England somehow? Maybe even excommunicate their King?
Or a clergyman from Hungary. Would he then call more/greater crusades against the Ottomans?
Or something similiar with any Spanish kingdoms before the Reconquista was completed?
Quite. People seem to conflate excommunication with Papal inderdicts declared upon entire countries. The latter saw considerable unrest forment, due to the censure of ecclesiastical rites in the interdicted country. People couldn't be given last rites, be married in a church, or buried in churchyards.
And a Pope using that as a blatantly political tool is going to get irritating. The Pope is supposed to at least pretend he's not playing politics like any other prince.
How so? The Papacy spent most of the mediaeval era trying unsuccessfully to argue that they should be treated as the political overlords of all Christendom as well as the spiritual. It may have been only in the 11th century that they showed flashes of real power but even into the 15th century the Italian philosophers hotly debated the Pope's legal sovereignty over Kings. It may have been a nuisance dealing with a Pope who claimed to have more power and influence than he actually had, but it was also accepted fact that that was how Popes behaved.