I've been trying to wrap my head around the semidirect product of two groups, and I think I'm starting to get it, but I wanted to double check if this is true or not.
If $N$ and $H$ are subgroups of $G$ and $N\triangleleft G$, then if $|HN|=|H||N|$, there exists a homomorphism $f: H\rightarrow\operatorname{Aut}(N)$ defined by $f_h(n)=hnh^{-1}$ and $G=N\rtimes H$.
Is this accurate? If not, what would a counterexample look like?
You're almost exactly right! We also need to know that $G$ is finite and $|HN| = |H||N| = |G|$.
Really the criterion for a semidirect product that you want (which can be found on wikipedia) is that both of the following hold:
1. $$ HN = \{hn \mid h \in H, n \in N\} = G $$
2. $$H \cap N = \{ e \}$$
In the case that $G$ is finite, $|HN| = |G|$ is equivalent to saying $HN = G$, and $|HN| = |H||N|$ is equivalent to saying $H \cap N = \{ e \}$.
You ask for counterexamples, though, and if we leave out the $|HN| = |G|$ assumption you might consider $N \vartriangleleft G$ and $H = \{e\}$. Then trivially $|HN| = |N| = |H||N|$, but if $N$ is a proper normal subgroup then $G \neq H \ltimes N \cong N$.
If we leave out the assumption that $G$ is finite, then you might try $N = 2\mathbb{Z}$ and $H = 3\mathbb{Z}$ as subgroups of $\mathbb{Z}$. Then $HN = G$, since every integer is the sum of a multiple of $2$ and a mulitple of $3$, and $|H||N| = |HN| = |G| = \aleph_0$, but $G \neq H \ltimes N$ since $H \cap N \neq \{0\}$.
I hope this helps ^_^