Let $X$ be a topological space with $Y$ a closed subspace with relative topology. If $f:Y \rightarrow Z$ is a continuous map of topological spaces, then can $f$ always be extended to be from $X$ to $Z$? If not, if possible, please provide a counterexample where $X, Y, Z$ are all metric spaces. (Euclidean space if possible)
I was looking into examples with $X$ being the cantor set. But my intuition for such pathological things is not great. I also tried examples where $X$ is a finite set with funny topologies, but got nowhere.
The identity map $S^{n-1}\to S^{n-1}$ cannot be extended to a continuous map $B^{n}\to S^{n-1}$ (see Brouwer's theorem). The simplest instance of this is the case $n=1$, when $S^{0}=\{-1,1\}$ and $B^1=[-1,1]$; then the conclusion follows from the intermediate value theorem.
A space $Z$ is an absolute retract if the extension property in your question holds for all $(X,Y)$ pairs. I'm not sure this notion is really used for general $ Y$; usually one assumes $Y$ normal (thus defining the absolute retract property in the class of normal spaces) or a metric space. This property is often abbreviated AR. It comes up in General Topology by Willard; there are also two books titled Theory of Retracts, one of them by Borsuk.
E.g., vector spaces are absolute retracts. The AR property forces the topology of $Z$ to be more or less trivial (namely, all homotopy groups are trivial). But a related property ANR (absolute neighborhood retract) is satisfied by many interesting spaces. E.g., the survey Absolute Neighborhood Retracts and Shape Theory by Sibe Mardesic.