Let $f:A\rightarrow Y$ and $g:Y\rightarrow W$ be cointinuous functions and let $A\subseteq X$ be a closed subset. I am asked to show that the following adjunction spaces are homeomorphic: $$(X\cup_f Y)\cup_g W$$ and $$X\cup_{g\circ f} W.$$ I've been thinking about what elements are related. In the first case, we have $x\sim f(x)$ and then $y\sim g(y)$, where $y$ can belong to $f(A)$ or not. In the second case we have $x\sim g(f(x))$, so the elements of $Y\setminus f(A)$ are not being glued.
Since they seem to be different, I don't know how to start the proof. I guess that I should use the hypothesis that $A$ is closed, but I don't know how.
I will use "$\sqcup$" for disjoint union. By "map" I mean continuous function. First, note that $A$ closed implies that the canonical map $j:W \to X \sqcup W \to X \cup_{gf} W$ (inclusion and then projection) is an embedding onto a closed subspace.
First define a map $\alpha = 1_X + g:X \sqcup Y \to X \sqcup W$ by $\alpha(x) = x$, $\alpha(y) = g(y)$. Compose with the quotient map to get a map $\alpha':(X \sqcup Y) \to (X \cup_{gf} W)$. By the gluing relations, this induces a map $\alpha'':(X \cup_f Y) \to (X \cup_{gf} W)$. Then, the map $\alpha'' + j:(X \cup_f Y) \sqcup W \to (X \cup_{gf} W)$ induces our homeomorphism-to-be $\phi:(X \cup_f Y) \cup_g W \to (X \cup_{gf} W)$.
Going the other way around, we have a map $i:X \to X \sqcup Y \to (X \cup_f Y)$ which is the composition of the inclusion with the projection. This gives a map $\beta = i+1_W:X \sqcup W \to (X \cup_f Y) \sqcup W$. Composing this with the quotient map, we get $\beta':X \sqcup W \to (X\cup_f Y) \cup_g W$. Again, by the gluing relations, this yields an induced map $\psi:X \cup_{gf} W \to (X\cup_f Y) \cup_g W$.
Chasing the definitions around, we check that $\phi,\psi$ are inverses. First, look at how $\phi$ is defined. Represent $[z] \in (X \cup_f Y) \cup_g W$ by an element $z \in (X \cup_f Y) \sqcup W$. If $z \in W$, $\phi([z]) = j(z)$. If $z = [w] \in X \cup_f Y$, $\phi([z]) = \alpha''(z)$. This reduces to $\phi([z]) = \{w\}$ if $w \in X$ and $\phi([z]) = \{g(w) \}$ if $w \in Y$. (Here the curly brackets denote equivalence classes in $X \cup_{gf} W$.) Next, look at how $\psi$ is defined. Represent $\{z\} \in X \cup_{gf} W$ by $z \in X \sqcup W$. Then $\psi(\{z\}) = [z]$ if $z \in W$ and $\psi(\{z\}) = [i(z)]$ if $z \in X$. So:
These computations are so trivial that they leave one feeling rather silly; have we really done anything here? Well, yes: while it is obvious that $\phi$ and $\psi$ must be inverses, what their long-winded definitions really show is that they are well-defined and continuous.
In my opinion, a more satisfying way to see why this is true is as follows: note that the adjunction space is a pushout in the category of topological spaces. Moreover, the concatenation of two pushout squares is also a big pushout square (rectangle). Uniqueness of the pushout yields the statement that we seek to prove.