Restrict the domain of $f(x)$ to find inverse:
\begin{align} f(x) & = x^2+6x+9 = (x+3)^2 \\ g(x) & = \sqrt{x} - 3 \end{align}
Restrict the domain of $f(x)$ to find inverse:
\begin{align} f(x) & = x^2+6x+9 = (x+3)^2 \\ g(x) & = \sqrt{x} - 3 \end{align}
The function $f$ is not one-to-one on $\Bbb R$, so in order to find an inverse for $f$, you need to find a subset $D$ of $\Bbb R$ on which $f$ is one-to-one. The graph of $y=(x+3)^2$ is symmetric about the line $x=-3$. This means that values of $x$ equidistant from $-3$ have the same image under $f$: for any $a$,
$f(-3+a)=\big((-3+a)=3\big)^2=a^2=(-a)^2=\big((-3-a)+3\big)^2=f(-3-a)\;.$
Thus, $D$ cannot contain both $-3+a$ and $-3-a$ for any $a$. The simplest ways to arrange this are to take $D$ to be either $[-3,\to)=\{x\in\Bbb R:x\ge -3\}\tag{1}$ (also written $[-3,\infty)$) or $(\leftarrow,-3]=\{x\in\Bbb R:x\le -3\}\tag{2}$ (also written $(-\infty,-3]$).
$D=[-3,\to)=\{x\in\Bbb R:x\ge -3\}\;.$
Now go back to $y=(x+3)^2$ and solve for $x$ in terms of $y$: $x+3=\pm\sqrt y$, and $x=\pm\sqrt y-3$. If we choose the positive square root, we get the function $g(x)=\sqrt x-3$; if we choose the negative square root, we get the function $h(x)=-\sqrt x-3$. Each of these is an inverse of $f$ on some domain, and it’s not hard to check that $g$ goes with the domain $(1)$ and $h$ with the domain $(2)$: for any $x\ge 0$, $g(x)=\sqrt x-3\ge-3$ and $h(x)=-\sqrt x-3\le-3$.
In most contexts it’s more natural to choose the function $g$ and the domain $(1)$: the function $g(x)=\sqrt x-3$ is the inverse of the restriction of $f$ to the domain $[-3,\to)$.