Suppose $X, Y$ are smooth manifolds, $Z \subset X$ a compact submanifold and $f: X \rightarrow Y$ a smooth map such that the restriction of $f$ to $Z$ is an injective smooth immersion. As $Z$ is compact, the restriction is actually a smooth embedding.
Is it true that $f$ is a smooth embedding in some open neighbourhood of $Z$, and if so, how can this be seen?
First, an example: Let $X$ denote the (open) Moebius band, $Y=S^1\times {\mathbb R}$ and let $Z$ denote the "core curve'' in $X$, i.e., if we think of $X$ as the total space of a nontrivial line bundle over $S^1$, then $Z$ is the image of the zero section. Now, let $p: X\to Z$ denote the natural projection and $i: Z\to Y$ the embedding $i: S^1\to S^1\times (0) \subset S^1\times {\mathbb R}$. Then $f=i\circ f$ is a smooth map which is the embedding $i$ when restricted to $Z$. However, the map $i$, clearly, does not extend to an embedding of a neighborhood of $Z$ in $X$.
Now, the correct statement is:
Lemma. An embedding $i: Z\to Y$ extends to an embedding $h$ of a neighborhood of $Z$ into $Y$ if and only if the map $i$ extends to a monomorphism $\mu$ of normal bundles $\nu_Z\to \nu_{i(Z)}$ where the first normal bundle is in $X$ and the second is in $Y$.
Proof. If $h$ exists, then its differential $dh$ induces a monomorphism of normal bundles. Conversely, suppose that $\mu$ exists. I will assume that $X, Y$ are equipped with Riemannian metrics. We need the following standard fact:
Let $M\subset N$ be a compact submanifold and $N$ is Riemannian, let $\nu_M$ denote the normal bundle. Let $exp_M: \nu_M\to N$ denote the normal exponential map: It sends the normal vector $v$ to the point $exp(v)$. Then there exists $r>0$ such that the restriction of $\exp_M$ to $B_r(\nu_M))$ is a diffeomorphism to its image. Here $B_r(\nu_M))$ consists of normal vectors of lengths $<r$.
Now, define $h$ to be the composition $\exp_{i(Z)}\circ \mu \circ (\exp_{Z})^{-1}$, defined on a sufficiently small open neighborhood $U$ of $Z$ in $X$. Then $h$ is a diffeomorphic extension of $i$ (provided that $U=exp_Z(B_r(\nu_Z))$ with $r$ sufficiently small. qed
Edit: Assume that $$ dim(Z) + dim(X)\le dim(Y). $$ Then there exists a monomorphism of normal bundles $$ \nu_Z\to \nu_{i(Z)}. $$ This follows immediately from the Existence Theorem in this paper, since the inequality of dimensions implies vanishing of the bordism group where the obstruction to existence of a monomorphism lies. In particular, in this range of dimensions, the map $i$ extends to an embedding of a tubular neighborhood of $Z$. Note that in my example the above inequality fails by 1, so it is sharp.