[proofplan]
We prove both directions using the open-set definition of continuity. If $f$ is continuous into the subspace $A$, then the preimage of every open set $V \subset Y$ under $i \circ f$ is the same as the preimage under $f$ of the subspace-open set $A \cap V$. Conversely, if $i \circ f$ is continuous into $Y$, then every open set in $A$ has the form $A \cap V$ with $V$ open in $Y$, and its preimage under $f$ is the preimage of $V$ under $i \circ f$.
[/proofplan]
[step:Declare the topologies and the inclusion map]
Let $\tau_A$ denote the subspace topology on $A$, so
\begin{align*}
\tau_A = \{A \cap V : V \in \tau_Y\}.
\end{align*}
Let
\begin{align*}
i: A &\to Y \\
a &\mapsto a
\end{align*}
be the inclusion map. The composite map
\begin{align*}
i \circ f: X &\to Y \\
x &\mapsto f(x)
\end{align*}
is well-defined because $f(x) \in A \subset Y$ for every $x \in X$.
[/step]
[step:Show that continuity into $A$ implies continuity into $Y$]
Assume that $f: (X,\tau_X) \to (A,\tau_A)$ is continuous. Let $V \in \tau_Y$ be an open subset of $Y$. Since $A$ carries the subspace topology, $A \cap V \in \tau_A$. By continuity of $f$, the set $f^{-1}(A \cap V)$ belongs to $\tau_X$.
For every $x \in X$, because $f(x) \in A$, we have
\begin{align*}
x \in (i \circ f)^{-1}(V)
&\iff i(f(x)) \in V \\
&\iff f(x) \in V \\
&\iff f(x) \in A \cap V \\
&\iff x \in f^{-1}(A \cap V).
\end{align*}
Thus
\begin{align*}
(i \circ f)^{-1}(V)=f^{-1}(A \cap V).
\end{align*}
The right-hand side is open in $X$, so $(i \circ f)^{-1}(V) \in \tau_X$. Since this holds for every $V \in \tau_Y$, the map $i \circ f: (X,\tau_X) \to (Y,\tau_Y)$ is continuous by the [open-set characterization of continuity](/page/Continuity).
[guided]
Assume that $f: (X,\tau_X) \to (A,\tau_A)$ is continuous. To prove that $i \circ f: (X,\tau_X) \to (Y,\tau_Y)$ is continuous, we use the open-set definition of continuity: for every open set $V \in \tau_Y$, we must prove that $(i \circ f)^{-1}(V)$ is open in $X$.
Fix an arbitrary $V \in \tau_Y$. The map $f$ is continuous only as a map into $A$, so we need an open subset of $A$ rather than merely an open subset of $Y$. The [subspace topology](/page/Subspace%20Topology) supplies exactly this: since $V$ is open in $Y$, the intersection $A \cap V$ is open in $A$, that is,
\begin{align*}
A \cap V \in \tau_A.
\end{align*}
By continuity of $f: (X,\tau_X) \to (A,\tau_A)$, the preimage of this open subset of $A$ is open in $X$:
\begin{align*}
f^{-1}(A \cap V) \in \tau_X.
\end{align*}
It remains to identify this set with the preimage of $V$ under $i \circ f$. For each $x \in X$, the value $f(x)$ lies in $A$ because the codomain of $f$ is $A$. Therefore
\begin{align*}
x \in (i \circ f)^{-1}(V)
&\iff (i \circ f)(x) \in V \\
&\iff i(f(x)) \in V \\
&\iff f(x) \in V \\
&\iff f(x) \in A \cap V \\
&\iff x \in f^{-1}(A \cap V).
\end{align*}
The only point in this chain that uses the codomain condition $f: X \to A$ is the implication $f(x) \in V \iff f(x) \in A \cap V$: since $f(x)$ is already known to belong to $A$, membership in $V$ is equivalent to membership in the intersection $A \cap V$.
Hence
\begin{align*}
(i \circ f)^{-1}(V)=f^{-1}(A \cap V).
\end{align*}
The right-hand side is in $\tau_X$, so $(i \circ f)^{-1}(V) \in \tau_X$. Since $V \in \tau_Y$ was arbitrary, every open subset of $Y$ has open preimage under $i \circ f$. By the [open-set characterization of continuity](/page/Continuity), $i \circ f$ is continuous.
[/guided]
[/step]
[step:Show that continuity into $Y$ implies continuity into $A$]
Assume that $i \circ f: (X,\tau_X) \to (Y,\tau_Y)$ is continuous. Let $U \in \tau_A$ be an open subset of $A$. By the definition of the subspace topology, there exists $V \in \tau_Y$ such that
\begin{align*}
U = A \cap V.
\end{align*}
By continuity of $i \circ f$, the set $(i \circ f)^{-1}(V)$ belongs to $\tau_X$.
For every $x \in X$, since $f(x) \in A$,
\begin{align*}
x \in f^{-1}(U)
&\iff f(x) \in U \\
&\iff f(x) \in A \cap V \\
&\iff f(x) \in V \\
&\iff i(f(x)) \in V \\
&\iff x \in (i \circ f)^{-1}(V).
\end{align*}
Thus
\begin{align*}
f^{-1}(U)=(i \circ f)^{-1}(V).
\end{align*}
The right-hand side is open in $X$, so $f^{-1}(U) \in \tau_X$. Since this holds for every $U \in \tau_A$, the map $f: (X,\tau_X) \to (A,\tau_A)$ is continuous by the [open-set characterization of continuity](/page/Continuity).
[guided]
Assume that $i \circ f: (X,\tau_X) \to (Y,\tau_Y)$ is continuous. To prove that $f: (X,\tau_X) \to (A,\tau_A)$ is continuous, we must show that the preimage under $f$ of every open subset of $A$ is open in $X$.
Let $U \in \tau_A$ be arbitrary. Because $\tau_A$ is the subspace topology inherited from $Y$, the definition of $\tau_A$ gives an open set $V \in \tau_Y$ such that
\begin{align*}
U = A \cap V.
\end{align*}
This representation is the key point: it lets us translate a preimage under $f$ of an open set in $A$ into a preimage under $i \circ f$ of an open set in $Y$.
Since $i \circ f$ is continuous and $V$ is open in $Y$, the open-set definition of continuity gives
\begin{align*}
(i \circ f)^{-1}(V) \in \tau_X.
\end{align*}
We now prove that this open set is exactly $f^{-1}(U)$. For every $x \in X$, the codomain condition $f: X \to A$ gives $f(x) \in A$. Therefore
\begin{align*}
x \in f^{-1}(U)
&\iff f(x) \in U \\
&\iff f(x) \in A \cap V \\
&\iff f(x) \in V \\
&\iff i(f(x)) \in V \\
&\iff (i \circ f)(x) \in V \\
&\iff x \in (i \circ f)^{-1}(V).
\end{align*}
The equivalence between $f(x) \in A \cap V$ and $f(x) \in V$ is valid because $f(x)$ is already known to lie in $A$.
Thus
\begin{align*}
f^{-1}(U)=(i \circ f)^{-1}(V).
\end{align*}
The right-hand side belongs to $\tau_X$, so $f^{-1}(U)$ is open in $X$. Since $U \in \tau_A$ was arbitrary, every open subset of $A$ has open preimage under $f$. By the [open-set characterization of continuity](/page/Continuity), $f$ is continuous.
[/guided]
[/step]
[step:Combine the two implications]
The first implication proves that continuity of $f: (X,\tau_X) \to (A,\tau_A)$ implies continuity of $i \circ f: (X,\tau_X) \to (Y,\tau_Y)$. The second implication proves the converse. Therefore
\begin{align*}
f \text{ is continuous}
\iff
i \circ f \text{ is continuous}.
\end{align*}
This proves the theorem.
[/step]