In group theory, we saw that if $G$ is a group over a set $X$, then we can embed $G$ into $S_X$, where $S_X$ is the group of permutations on $X$, i.e. there is an injective homomorphism $G \hookrightarrow S_X$ (Cayley's theorem). Similarly, in real analysis, we saw that we can isometrically embed any metric space $(M,d)$ into another metric space $(\hat{M},\hat{d})$ where the image of $M$ under our isometry is dense in $\hat{M}$. But these facts were proved in similar ways. For groups, we map each $g \in G$ to $g \mapsto \sigma_g$ where $\sigma_g$ is defined as $\sigma_g(x) = gx$. For metric spaces, we fix $a \in M$ and map each $x \in M$ to $x \mapsto f_x$ where $f_x(y) = d(x,y) - d(a,x)$. The desired results follow.
Is there something more general "going on", or is it just a coincidence that these results are proved in a similar way?