The isomorphism $f^\* q^\* \cong p^\*$$f^* q^* \cong p^*$ induced by $q_\* f_\* \cong p_\*$$q_* f_* \cong p_*$ is defined to be the composition
$f^\* q^\* \to f^\* q^\* p_\* p^\* \cong f^\* q^\* q_\* f_\* p^\* \to f^\* f_\* p^\* \to p^\*$$f^* q^* \to f^* q^* p_* p^* \cong f^* q^* q_* f_* p^* \to f^* f_* p^* \to p^*$.
Now it is easily checked that the two definitions of the morphism agree. In fact, the first one is more natural, whereas the second one is somehow artificial since it coindices with the first one plus an expansion of the isomorphism $f^\* q^\* \cong p^\*$$f^* q^* \cong p^*$, which is then removed again.
More generally, if $p: X \to S,~ p' : X' \to S,~ q' : X' \to X, ~q : S' \to S$ are morphisms (in your case $p=id$) such that the obvious diagram commutes, then there is a natural transformation $p'^\* q_\* \to q_\* p'^\*$$p'^* q_* \to q_* p'^*$. It is studied, for example, in EGA I, 9.3. Remark that we only use here that we have a weakly commutative diagramm of categories and functors such that the vertical functors $p_\*,p'_\*$$p_*,p'_*$ have left adjoints. See this paper by Calmes, Hornbostel (Lemma 1.2.6) for a generalization to categories.