One is supposed to do hishtadlus but not supposed to overdo it. In the case of Yaakov, each part of the action was different and was part of the proper hishtadlus. That is, prayer, bribery, and preparation for war were separate actions each of which were appropriate ways of setting up the situation.
Yosef on the other hand, asked the butler to remember him. That was the action of hishtadlut and was proper. He then asked a second time , which repeated the action which was improper. There are meforshim who ask:
Since Yosef was punished by a two year delay for asking twice, What
would his punishment have been had he only asked once?
The answer is none, since that was proper hishtadlus.
An analogy is given to buying a lottery ticket. One ticket is hishtadlus, more than one is not proper.
The Chazon Ish in his sefer Emunah U'Vitachon says that the act of asking in such a specific way of the butler was an improper histadlus because the character of the butler was such that the act itself was not normal hishtadlus but an act of desperation normally carried out by someone lacking in bitachon. The Art Scroll biography in Chapter 10, Emunah and Bitachon, in the subsectionThe Role of Hishtadlus, quotes the Chazon Ish as follows.
Yosef knew that his rescue was not dependent on hishtadlus, for all
is from Hashem. Only, since a person is obligated to act and not rely
on miracles, Yosef obligated himself to utilize this opportunity and
make his request of the cup bearer. However, since the arrogant by
nature do not remember others to do them good, this act [of requesting
the cup-bearer's help] is only fit for one who has despaired, for such
a person makes every possible effort, even that which is distant from
achieving any results. The bote'ach (one possessing bitachon),
though, does not do such things, and such efforts are not obligated.
To the contrary, engaging in them is like throwing dust upon the
radiance of one's emunah and bitachon. Once such an act is not
deemed obligatory, it becomes forbidden.
The biographer comments that it was not a lack of bitachon but a mistake in analyzing what hishtadlus required:
Thus, Yosef epitomized the classic botei'ach; however he erred in
this single instance.
Torah.org cites the medrash
The midrash comments on this: “‘Praiseworthy is the man who has made
Hashem his trust’ (Tehilim 40:5) – this is Yosef – ‘and turned not to
the arrogant’ (bid) – because Yosef said to Pharaoh’s butler, ‘If only
you would think of me,’ and, ‘mention me,’ he remained in prison an
extra two years.”
The article cites the standard meforshim
Many commentaries ask: This midrash appears to contradict itself!
First it states that the one “who has made Hashem his trust” is Yosef.
Then it appears to say that Yosef was punished for placing his trust
in the butler! Most commentaries explain that the first half of the
midrash gives the background for the second half. For most people, it
would not be a sin to ask the butler for help. “G-d helps those who
help themselves.” However, because Yosef usually placed his trust in
Hashem to an extraordinary degree, it was a failing on his part to ask
the butler for help. (This answer is given by Bet Halevi and others.)
However, it gives an alternative explanation by R’ Azaryah Figo z”l (1579-1647).
He explains that Yosef never placed his trust in the butler, and Hashem left Yosef in jail for an extra two years in order to demonstrate this. He interprets Yosef’s words to the butler as follows:
“Even if you would think of me with yourself when [Pharaoh] benefits you,
and [even if] you will do me a kindness and mention me
to Pharaoh, the most you could do is to get me out of this building.
[That would solve my immediate physical problem, but not my spiritual
problem.] For indeed I was kidnaped from the land of the Hebrews [and
thus expelled from before G-d]. Here I have done nothing for [my
spiritual betterment, and therefore G-d has caused that they] have put
me in the pit.”
Without this interpretation, says R’ Figo, one might wonder how the
butler could be so ungrateful as to forget Yosef. With this
interpretation, however, it is understandable; in effect, Yosef told
the butler that his help was not wanted. The reason Yosef said this
was to emphasize that the interpretation of dreams comes from Hashem
and that Yosef deserved no credit.
Just to make clear that Yosef never expected help from the butler,
Hashem caused the butler to forget Yosef and leave Yosef in jail. The
last verse of last week’s parashah states, “And the butler did not
remember Yosef, and he forgot him.” Why the redundant language – “did
not remember” and “forgot”? In line with the above interpretation, R’
Figo suggests that the phrase, “and he forgot him,” means that Yosef
forgot the butler. (Binah La’ittim: Drush Rishon Le’Chanukah)
Chabad.org points out that if the butler had remembered Yosef immediately and gotten him released, Yosef would not have been raised to become the viceroy of Egypt and saved his family and set up the persecution in Egypt and the Exodus. Hashem had to make the butler forget until it was time for Pharaoh to have the dream in order to call Yosef from the prison.
The answer lies in the dynamics of Joseph’s story itself. What would
have happened had Joseph been released in time? What would Joseph have
done on the other side? He would have been known as an ex-convict, and
would have struggled to find his place within Egyptian society.
As it happened, he waited two short years until Pharaoh had a dream
that would require interpretation, and the butler remembered him for
his uncanny interpreting abilities. Joseph was brought before Pharaoh
and successfully interpreted the dream. Pharaoh was extremely
impressed, and appointed him viceroy of Egypt. Had Joseph been
released two years earlier, the butler would likely not have known
where to find him, and a historic opportunity would have been lost.
Thus, the punishment was that Hashem did not send the dream until the second birthday after the release of the butler. Had Yosef not had the punishment, perhaps Hashem would have sent the dream the next birthday and the butler would have remembered Yosef (who predicted he would be spared) even without Yosef having asked for help.