The implication (2) $\Rightarrow $ (1) follows from Algebra, Lemma 10.141.2. Conversely, if $A \to B$ is smooth at $\mathfrak q$, then $A \to B_ g$ is smooth for some $g \in B$, $g \not\in \mathfrak q$. Then $A \to B_ g$ is formally smooth by Algebra, Proposition 10.138.13. Hence $A_\mathfrak p \to B_\mathfrak q$ is formally smooth as localization preserves formal smoothness (for example by the criterion of Algebra, Proposition 10.138.8 and the fact that the cotangent complex behaves well with respect to localization, see Algebra, Lemmas 10.134.11 and 10.134.13). Finally, Lemma 15.37.2 implies that $A_\mathfrak p \to B_\mathfrak q$ is formally smooth in the $\mathfrak q$-adic topology.