Let $X$ be a compact metric space, $A\subset X$ a closed subset and $f:A\to A$ be a continuous map. Can $f$ be extended to a continuous map $X\to X$? If so, is there an extension which is injective if $f$ is? If not, are there handy additional conditions under which it holds?

$\begingroup$ A lot can be said for the case of Lipschitz extensions. For example, if $X$ were a Hilbert space, then by Kirszbraun's theorem, any Lipschitz map from a subset of $X$ may be extended to a Lipschitz map on the whole domain with the same Lipschitz constant. Morever, due to McShane (1934), there are also results on the extension of Lipschitz maps from metric spaces into finite dimensional euclidean spaces. $\endgroup$ – Peter Wildemann Dec 30 '18 at 18:28
Let $G = \langle a,b \mid R \rangle$ be a 1relator group. To this presentation we obtain a twodimensional CWcomplex $X$ by attaching a two cell to $S^1\vee S^1$ via the relator. Let $A=S^1\vee S^1$ be the one skeleton of $X$.
A continuous map $f:A\rightarrow A$ gives us two group elements in $\pi_1(X)=G$; the images of the generators $a,b$, i.e. the two circles in $A$. Any choice of pairs of group elements arises this way. Extending this map works only if the images satisfy the same relation, and this need not be the case. There are plenty of such onerelator groups.
If we choose for $f:A\rightarrow A$ the injective map that swaps the two circles, and our relator is not symmetric enough in $a,b$, there cannot be an extension of $f$.
Consider $X = [0,1] \cup \{2\}$, $A = \{0,1,2\}$, and let $f:A \to A$ with $f(0)=0$, $f(1)=2$, $f(2)=0$. For any extension $g: X \to X$, $g([0,1])$ would not be connected so $g$ couldn't be continuous.
EDIT: For a more general class of examples, let $X = Y \times [0,1]$ and $A = Y \times \{0,1\}$ for some $Y$ such that the maps $y \mapsto f(y, 0)_1$ and $y \mapsto f(y,1)_1$ from $Y$ to $Y$ are not homotopic.

$\begingroup$ For the same $X$ you could just use $A = \{0,1\}$. $\endgroup$ – KConrad Dec 30 '18 at 15:36

$\begingroup$ @KConrad That would work if $f: A \to X$, but not $A \to A$. $\endgroup$ – Robert Israel Dec 30 '18 at 16:36

$\begingroup$ Ah, got it. I was sure I was missing something. $\endgroup$ – KConrad Dec 31 '18 at 3:59
Let $X = [0,3]$, $A$ is $X$ with $0$ removed, $f:A \to A$ is defined by $f(x) = 2+sin(1/x)$, then $f$ can't be extended to a continuous mapping from $X$ to $X$ simply because you can't define $f(0)$ without breaking continuity.