Note: After coming up with this argument I took a look at the comments and realized that it uses essentially the same idea as the one by Valerio De Angelis that darij grinberg found. I’m posting it anyway so as to have an answer here (and incidentally get the question off the unanswered list).
Suppose that we have $n$ arrows, numbered $1$ through $n$; in how many ways can we line them up end to end?
The easy answer is that since there are $n!$ possible orders in which we can line them up, and each arrow can point either to the left or to the right, there are $2^nn!$ possible lineups.
Each lineup can be thought of as an ordered pair $\langle\pi,d\rangle$, where $\pi=\langle\pi(1),\ldots,\pi(n)\rangle$ is a permutation of $[n]$, and $d=\langle d(1),\ldots,d(n)\rangle\in\{L,R\}^n$: for each $k\in[n]$, $\pi(k)$ is the number of the $k$-th arrow in the lineup, and $d(k)$ is the direction in which arrow $k$ (not arrow $p(k)$) points, $L$ for left and $R$ for right. Conversely, each such ordered pair is one of the $2^nn!$ possible lineups. It will be convenient to denote the head and tail of arrow $k$ by $h_k$ and $t_k$, respectively, and to denote its left and right ends of arrow $\pi(k)$, the $k$-th arrow in the lineup, by $e_k^L$ and $e_k^R$, respectively. Thus,
$$e_k^L=\begin{cases}
t_{\pi(k)},&\text{if }d(\pi(k))=R\\
h_{\pi(k)},&\text{if }d(\pi(k))=L\,,
\end{cases}$$
and
$$e_k^R=\begin{cases}
h_{\pi(k)},&\text{if }d(\pi(k))=R\\
t_{\pi(k)},&\text{if }d(\pi(k))=L\,.
\end{cases}$$
Let $\lambda=\langle\pi,\delta\rangle$ be a lineup. For $k\in[n]$ say that $\pi$ has a left peak at $k$ if $\pi(i)<\pi(k)$ for $1\le i<k$; clearly $\pi$ has a left peak at $1$. The left peaks divide $\pi$ into segments. If $\pi$ has left peaks $\ell_1,\ell_2,\ldots,\ell_m$, where $1=\ell_1<\ell_2<\ldots<\ell_m$, the segments $\sigma_1^\lambda,\ldots,\sigma_m^\lambda$ and associated sets $S_1^\lambda,\ldots,S_m^\lambda$ are defined as follows:
- if $k<m$ and $\ell_{k+1}=\ell_k+1$, then $\sigma_k^\lambda=\langle\pi(\ell_k)\rangle$ and $S_k^\lambda=\{\pi(\ell_k)\}$;
- if $k<m$ and $\ell_{k+1}>\ell_k+1$, then $\sigma_k^\lambda=\langle\pi(\ell_k),\ldots,\pi(\ell_{k+1}-1)\rangle$, and $S_k^\lambda=\{\pi(\ell_k),\ldots,\pi(\ell_{k+1}-1)\}$;
- if $\ell_m=n$, then $\sigma_m^\lambda=\langle\pi(n)\rangle$ and $S_m^\lambda=\{\pi(n)\}$; and
- if $\ell_m<n$, then $\sigma_m^\lambda=\langle\pi(\ell_m),\ldots,\pi(n)\rangle$ and $S_m^\lambda=\{\pi(\ell_m),\ldots,\pi(n)\}$.
Say that the segment $\sigma_k^\lambda$ is positive if $d(\pi(\ell_k))=R$, and let $P^\lambda$ be the union of the positive segments.
For each segment $\sigma_k^\lambda$ let $E_k^\lambda=\left\{h_{\pi(i)}:\pi(i)\in S_k^\lambda\right\}\cup\left\{t_{\pi(i)}:\pi(i)\in S_k^\lambda\right\}$, the set of ends of the arrows in the segment; we define a partition $\mathscr{P}_k^\lambda$ of $E_k^\lambda$ into pairs as follows.
- $\mathscr{P}_k^\lambda=\big\{\{t_{\pi(r)},h_{\pi(r)}\}\big\}$ if $S_k^\lambda=\{\pi(r)\}$.
- $\mathscr{P}_k^\lambda=\left\{\left\{e_i^R,e_{i+1}^L\right\}:i=r,\ldots,s-1\right\}\cup\left\{\left\{e_s^R,e_r^L\right\}\right\}$ if $S_k^\lambda=\{\pi(r),\pi(r+1),\ldots,\pi(s)\}$ and $s>r$.
In other words, we pair the two ends that aren’t adjacent to another arrow in the segment, and if there is more than one arrow in the segment, we pair neighboring ends of adjacent arrows.
Let $E^\lambda=\bigcup_{k=1}^mE_k^\lambda$ and $\mathscr{P}^\lambda=\bigcup_{k=1}^m\mathscr{P}_k^\lambda$; then $\mathscr{P}^\lambda$ is a partition of $E^\lambda$ into pairs such that
- every member of $\mathscr{P}^\lambda$ has the form $\left\{e_i^R,e_j^L\right\}$ for some $i,j\in[n]$, and
- if $\left\{e_i^R,e_j^L\right\}\in\mathscr{P}^\lambda$, then either $\pi(i),\pi(j)\in P^\lambda$, or $\pi(i),\pi(j)\in[n]\setminus P^\lambda$.
Let $E=\{h_k:k\in[n]\}\cup\{t_k:k\in[n]\}$. Let $\Bbb P$ be the set of ordered pairs $\langle P,\mathscr{P}\rangle$ such that $P\subseteq[n]$, and $\mathscr{P}$ is a partition of $E$ into pairs such that if $\{e_i,e_j\}\in\mathscr{P}$, where $e_i\in\{h_i,t_i\}$ and $e_j\in\{h_j,t_j\}$, then either $i,j\in P$, or $i,j\in[n]\setminus P$; I claim that for each $\langle P,\mathscr{P}\rangle\in\Bbb P$ there is a lineup $\lambda=\langle\pi,d\rangle$ such that $P^\lambda=P$ and $\mathscr{P}^\lambda=\mathscr{P}$.
To construct $\lambda$ we use $\mathscr{P}$ to identify the segments of $\pi$ and add information from $P$ to define $d$. First, any pair of the form $\{h_i,t_i\}$ yields a segment $\langle i\rangle$, and we set $d(i)=R$ iff $i\in P$.
Now consider a pair $\{e_{i_0},e_{i_1}\}$ with $i_0\ne i_1$; there is exactly one pair, say $\{e_{i_1}',e_{i_2}\}$, containing the other end of arrow $i_1$. Similarly, there is a unique pair $\{e_{i_2}',e_{i_3}\}$ containing the other end of arrow $i_2$. Continuing in this way, we must at some point reach a pair $\{e_{i_r}',e_{i_0}'\}$; then then $\{i_0,\ldots,i_r\}$ is the set associated with a segment. Without loss of generality we may assume that $i_0>i_k$ for $k\in[r]$: if it is not, we just ‘rotate’ the tuple $\langle i_0,\ldots,i_r\rangle$ to bring its largest element to the front and re-index the elements. Then either $\langle i_0,\ldots,i_r\rangle$ or $\langle i_0,i_r,i_{r-1},\ldots,i_1\rangle$ is the desired segment of $\pi$.
- If $i_0\in P$ and $e_{i_0}=h_{i_0}$, or if $i_0\notin P$ and $e_{i_0}=t_{i_0}$, then the segment is $\langle i_0,\ldots,i_r\rangle$. For $k\in[r]$ set $d(i_k)=R$ iff $e_{i_k}=t_{i_k}$, and set $d(i_0)=R$ iff $i_0\in P$.
- If $i_0\in P$ and $e_{i_0}=t_{i_0}$, or $i_0\notin P$ and $e_{i_0}=h_{i_0}$, then the segment is $\langle i_0,i_r,i_{r-1},\ldots,i_1\rangle$. For $k\in[r]$ set $d(i_k)=R$ iff $e_{i_k}=h_{i_k}$, and again set $d(i_0)=R$ iff $i_0\in P$.
This completely defines $d$, and $\pi$ is obtained by concatenating the segments from left to right in order of increasing first elements. It is slightly tedious but straightforward to verify that if $\lambda=\langle\pi,d\rangle$, then $P^\lambda=P$ and $\mathscr{P}^\lambda=\mathscr{P}$. This establishes a bijection between the set of lineups and $\Bbb P$, so $|\Bbb P|=2^nn!$. However, we can also calculate $|\Bbb P|$ directly as follows.
Fix $P\subseteq[n]$, and let $E_P=\{h_i:i\in P\}\cup\{t_i:i\in P\}$. Let $k=|P|$. If $\mathscr{P}$ is a partition of $E$ into pairs, then $\langle P,\mathscr{P}\rangle\in\Bbb P$ iff $\mathscr{P}$ is the union of a partition of $E_P$ into pairs and a partition of $E\setminus E_P$ into pairs. There are $(2k-1)!!$ partitions of $P$ into pairs and $(2n-2k-1)!!$ partitions of $E\setminus E_P$ into pairs, so there are $(2k-1)!!(2n-2k-1)!!$ partitions $\mathscr{P}$ such that $\langle P,\mathscr{P}\rangle$. Summing over all $P\subseteq[n]$, we see that $|\Bbb P|=\sum_{k=0}^n\binom{n}k(2k-1)!!\,(2n-2k-1)!!$ and hence that
$$\sum_{k=0}^n\binom{n}k(2k-1)!!\,(2n-2k-1)!!=2^nn!\,.$$