Universal property of $N\rtimes K$
Given groups $N$ and $K$, if $K$ acts on $N$ by \begin{equation} K\xrightarrow{\theta}\operatorname{Aut_{Grp}}(N), \end{equation} then we can define a group $N\rtimes_{\theta}K$ whose elements are like in $N\times K$ but the multiplication is defined by \begin{equation} (n,k)(n',k')=(n\theta_{k}(n'),kk') \end{equation} where $\theta_k\in \operatorname{Aut_{Grp}}(N)$ is the image of $k$ under $\theta$.
This semidirect product is very useful in studying structures of finite groups, especially it solves the extension problem \begin{equation} 1\longrightarrow N\longrightarrow N\rtimes_{\theta} K\longrightarrow K\longrightarrow 1. \end{equation} But I am wondering whether this can be defined using universal properties? In the abelian case $N\rtimes K$ is just $N\times K$ so we have the universal property of products, but what about the nonabelian case?
Thanks!
For the sake of the MSE search engine, I'm summarizing the discussion in the associated MO post.
First, note that each group can be considered to be a (relatively simple) category. If we assume that our semidirect factors $N$ and $K$ are encoded this way, then one can encode $\theta$ as a functor $K\to\textbf{Cat}$ sending $\star\mapsto N$. Post-encoding, one obtains a nice description of $N\rtimes K$ as a Grothendieck construction/Kan extension $\int^K{N}$. If you want fancy names, then this describes $N\rtimes K$ as a lax 2-colimit.
Unfortunately, you probably don't just want fancy names: you probably want a description of semidirect products that is element-free. The encoding process to make a lax 2-colimit construction elevates each element of $N$ and $K$ to a category morphism, which defeats the point. So can we give an element-free description?
Yes! Consider the morphism category $\textbf{Mor}(\textbf{Grp})$ which consists of group homomorphisms $A\to B$. An element $F\in\textbf{Mor}(\textbf{Grp})$ defines a map $A\to\text{Aut}(B)$; elements of $A$ act on $B$ by conjugating by the image under $F$. There is a forgetful functor dropping the specific map $A\to B$ in favor of the action $A\to\text{Aut}(B)$; the mapping taking $K\to\text{Aut}(N)$ to the inclusion $K\to N\rtimes K$ is the left-adjoint of that forgetful functor.
Both of these options are discussed on the $n$-CatLab.
Lastly, one might object that both of these constructions build the semidirect product as a colimits. One usually encounters semidirect products are a generalization of direct products, which are limits, so one might hope for a limit construction. But this is something of a coincidence: the direct product is a quotient of the semidirect product via $$N\times H=N*H/\langle\!\langle nhn^{-1}h^{-1}\rangle\!\rangle_{n\in N, h\in H}$$ where $\langle\!\langle\cdot\rangle\!\rangle$ denotes the normal closure generated by those elements. A semidirect product is a twist of this quotient via $$N\times H=N*H/\langle\!\langle nhn^{-1}\theta_h(n)^{-1}\rangle\!\rangle_{n\in N, h\in H}$$ Indeed, within the category of groups (or, really, any subcategory of pointed sets), a direct product has both projection and injection maps to and from (respectively) each direct factor. The projections are what makes it a direct product…and the condition that semidirect products choose to weaken.
Since this got bumped already today, I'll add another answer based on Martin Brandenburg's answer in the linked question. The point of this answer is to give a short and to the point answer that's (ideally) a little more transparent to beginners than the other existing answer.
If $\phi:K\to \newcommand\Aut{\operatorname{Aut}}\Aut(N)$, then $N\rtimes_\phi K$ is universal among groups $G$ with pairs of maps $i : N\to G$ and $j : K\to G$ such that for all $n\in N$, $k\in K$, $$ j(k)i(n)j(k)^{-1} = i(\phi_k(n)), $$ where $\phi_k=\phi(k)$, In the sense that for any such group $G$ there is a unique map $(i,j) : N\rtimes_\phi K \to G$ such that $(i,j)|_N = i$, and $(i,j)|_K = j$.
In words, $N\rtimes_\phi K$ is universal (initial) for groups $G$ with maps from $N$ and $K$ where the image of $K$ is in the normalizer of the image of $N$, the kernel of $N\to G$ is fixed (setwise) by the action of $K$, and the conjugation action of $K$ on the image of $N$ is given by $\phi$.
As discussed in the other answer, despite products being a special case of semidirect products, we only have injection maps and not projections for semidirect products, so they are a kind of colimit.
For other perspectives and more details read the other answer by Jacob Manaker or the MO answer by Martin Brandenburg.