In the US and UK, public prosecutors have "prosecutorial discretion," which means that they have mostly sole discretion of which alleged crimes they choose to prosecute. In the UK, the Crown Prosecution Service does have a set of guidelines on their prosecutors must follow when making the decision to prosecute, summarized as (emphasis mine):
Is there enough evidence against the defendant?
Is it in the public interest for the CPS to bring the case to court?
A prosecution will usually take place unless the prosecutor is sure that the public interest factors tending against prosecution outweigh those tending in favour.
As shown, the CPS errs on the side of allowing a case to be prosecuted if they have sufficient evidence that a crime has taken place, and only recommend declining to prosecute if the prosecutor is sure it is not in the public's best interest to prosecute. The fact that a particular prosecution fulfills a political purpose could be a factor against the public interest, but it seems that the prosecutor in Assange's case decided that allowing the courts to make the extradition decision was in the public interest as opposed to the prosecutor making the decision not to prosecute.
In the US, United States Attorneys (federal level chief prosecutors) are appointed by the President and are part of the Department of Justice. The Department of Justice has this set of guidelines on prosecutorial discretion:
The attorney for the government should commence or recommend federal prosecution if he/she believes that the person's conduct constitutes a federal offense, and that the admissible evidence will probably be sufficient to obtain and sustain a conviction, unless (1) the prosecution would serve no substantial federal interest; (2) the person is subject to effective prosecution in another jurisdiction; or (3) there exists an adequate non-criminal alternative to prosecution.
The guidelines here are different from the UK, the most important for the purpose of this question being that the prosecution must serve a substantial federal interest, rather than public. However, there is still no prohibition on prosecution that happens to serve a political purpose, so long as the prosecutor believes there is sufficient evidence to convict the accused and that it serves a substantive federal interest, along with the other factors. The US Attorney in this case apparently believes that crimes Assange is alleged to have committed serve a substantive federal purpose.
With all this in mind, the purpose of a grand jury is to prevent prosecution when there isn't sufficient evidence to establish probable cause of a person having committed a crime, which acts as a deterrent against prosecutial power being used to harass a person or drag them through a trial without any hope of convicting them. However, for the purpose of trial and conviction ultimately the law only cares whether or not there is sufficient evidence to convict someone of a crime, not whether that conviction serves a political purpose.
With all that said, extradition treaties are ultimately political vehicles - they generally allow the sending state to have the discretion to choose whether or not to extradite a person. If the UK extradites Assange to Sweden, Sweden may decide not to extradite him to the US due to their belief that prosecution for the charges is not in the Swedish public interest, possibly because they serve more of a political purpose for the US government than a judicial interest. There's no particular law compelling Sweden's government to act one way or another, so their possible choices on that front are a matter of politics and not law.