So, USA gives money to a country, and they use it for means other than those intended, the reasons for giving the money. The USA was taken for a ride = deceived and cheated by the Pakistani Government. The expression carries with it the implication that the person (or as here, the USA government giving the money) is naive, over-trusting, "green", with a touch of 'easily fooled/taken in' - like, the poor innocent didn't know what he was walking into and got taken for a ride.
Where/how the expression arose, perhaps some other post can say.
Student or Learner