The following solution is a detailed version of ploosu2 above.
We recall the following equality for the Bell number (see the link here)
$$B_{n+1}=\sum_{l=0}^n\binom{n}{l}B_l.$$
According to the binomial inverse formula, from the above equality we obtain
$$B_n=\sum_{l=0}^{n}(-1)^{n-l} \binom{n}{l}B_{l+1} \quad (\star)$$
Returning to the problem, for each number $i \in [n]$, let $A_i$ be the set of partitions of the set $[n+1]$ into component sets such that $i;i+1$ are in the same component set. Combining the inclusion-exclusion principle, we have
$$a_n=\left|\overline{\bigcup_{i=1}^n A_i} \right|=B_{n+1}+\sum_{\varnothing \neq I \subseteq[n]}(-1)^{|I|}\left|\bigcap_{i \in I} A_i\right|.
$$
For each fixed set $\varnothing \neq I \subseteq [n]$, let
$$C_I=\bigcap_{i \in I} A_i$$
and $D_{n+1-m}$ be the set of partitions of the set $[n+1] \setminus I$. We have, $|D_{n+1-m}|=B_{n+1-m}$.
We consider a mapping $f$ with the rule defined as follows: for $\alpha=\{X_1;X_2;\cdots;X_l\} \in C_I$ we associate it with $\beta=\{Y_1;Y_2;\cdots;Y_l\}$, where
$$Y_i = X_i \setminus I,\quad \forall i=1,2,\cdots,l.$$
We will prove that the mapping $f$ is a bijection from $C_I$ to $D_{n+1-m}$, from which it follows that $\left|\bigcap_{i \in I} A_i\right|=B_{n+1-m}$.
1. First, for each $\alpha$, we can uniquely determine a $\beta$ according to the rule above. We observe that
$\quad$ a) $Y_i \neq \varnothing$ for every $i$. Indeed, by definition, $Y_i=\varnothing$ if and only if
$$X_i \subseteq I.$$
Consider the largest element in $X_i$, assume it is $x$. Hence,
$$x \in I.$$
According to the definition of the set $A_{x}$, the set $X_i$ must contain both $x$ and $x+1$. This is a contradiction since $x$ is already the largest element.
$\quad$ b) $Y_i \cap Y_j = \varnothing$ for all $i \neq j$. Indeed,
$$(Y_i \cap Y_j) \subseteq (X_i \cap X_j) = \varnothing,\forall i=1,2,\cdots,l.$$
$\quad$ c) $\bigcup_{i \in I}Y_i=[n+1] \setminus I$. Indeed,
$$\bigcup_{i \in I}Y_i=\bigcup_{i \in I}\left(X_i \setminus I \right)=\left(\bigcup_{i \in I}X_i\right) \setminus I=[n+1]\setminus I.$$
Therefore, $f$ is a mapping from $C_I$ to $D_{n+1-m}$.
2. $f$ is an injective function. Suppose there exist $\alpha=\{X_1;X_2;\cdots;X_l\}$ and $\alpha^{\prime}=\{X_1^{\prime};X_2^{\prime};\cdots;X_l^{\prime}\} \in C_I$ such that
$$X_i \setminus I=X_i^{\prime} \setminus I, \forall i=1,2,\cdots,l.$$
For each $i$, our goal is to show that $X_i=X_i^{\prime}$ (this may not hold for arbitrary sets, but it holds here due to the special properties of $C_I$ and is not overly complex). Assume $X_i \neq X_i^{\prime}$ but because $X_i \setminus I=X_i^{\prime} \setminus I$, without loss of generality, we can assert that there exists $x$ such that
$$x \in X_i, x \in I, x \not \in X_i^{\prime} \quad (\star\star).$$
Among the $x$ satisfying $(\star\star)$, consider the largest element, assume it is $x'$. Hence, $x'+1 \in X_i$ (since $x' \in X_i, x' \in I$). Due to the largest element property of $x'$, $x'+1 \in X_i^{\prime}$. However, $\alpha^{\prime} \in C_I$, so $x'$ and $x'+1$ must belong to the same component set, that is, $x' \in X_i^{\prime}$. This is a contradiction. Therefore, $f$ is injective.
3. $f$ is surjective. Consider $\beta=\{Y_1;Y_2;\cdots;Y_p\} \in D_{n+1-m}$ (arbitrary), we construct
$$\alpha = \{X_1;X_2;\cdots;X_p\},$$
based on $\beta$ as follows: for each $i$, assume
$$Y_i=\{y_{i,1};y_{i,2};\cdots;y_{i,t}\} \text{ with } 1 \le y_{i,1}<y_{i,2}<\cdots<y_{i,t},$$
the set $X_i$ is determined by the algorithm below
$\quad\quad$ Step 1: Place all elements of $Y_i$ into $X_i$. Then move to step 2. Since $Y_i \in D_{n+1-m}$, $Y_i$ must contain at least one element, meaning $X_i$ is non-empty after step 1. We will call $Y_i$ the generating set of $X_i$.
$\quad\quad$ Step 2: Order the current elements of $X_i$. Without loss of generality, assume $X_i=\{x_{i,1};x_{i,2};\cdots;x_{i,v}\}$ with $1 \le x_{i,1}<x_{i,2}<\cdots<x_{i,v}$. Move to step 3.
$\quad\quad$ Step 3: If for each $x_{i,j} \in X_i$ we have $x_{i,j}-1 \not \in I$, then the algorithm for constructing $X_i$ terminates and we obtain $X_i$. Otherwise, consider the elements $x_{i,j}$ such that $x_{i,j}-1 \in I$. Then, add $x_{i,j}-1$ to $X_i$. Perform this for all such $x_{i,j}$ and then return to step 2.
(Since the elements in $I$ are bounded below by 1, the above algorithm will only execute a finite number of times)
In summary, through the above 3 steps, we obtain the set $X_i$. Without loss of generality, assume $X_i$ is then
$$\left\{ {\underbrace {\overbrace {{x_{{1,i_1}}};{x_{{1,i_2}}}; \cdots ;{x_{{1,i_q}}}}^{ \in I};{y_{i,1}}}_{\textrm{Consecutive integers}};\underbrace {\overbrace {{x_{{2,i_1}}};{x_{{2,i_2}}}; \cdots ;{x_{{2,i_r}}}}^{ \in I};{y_{i,2}}}_{\textrm{Consecutive integers}} \cdots ;\underbrace {\overbrace {{x_{{t,i_1}}};{x_{{t,i_2}}}; \cdots ;{x_{{t,i_u}}}}^{ \in I};{y_{i,t}}}_{\textrm{Consecutive integers}}} \right\}$$
with
$$
x_{1,i_1}<x_{1,i_2}<\cdots x_{1,i_q}<y_{i,1}<x_{2,i_1}<x_{2,i_2}<\cdots<x_{t,i_1}<x_{t,i_2}<\cdots<x_{t,i_u}<y_{i,t}
$$
(note that $x_{1,i_1},x_{1,i_2},\cdots,x_{1,i_q}$ may not exist, meaning the smallest element in $X_i$ is then $y_{i,1}$)
We have three observations about the sets $X_i$ formed:
$\quad\quad$ i) First, $Y_i \subseteq X_i, \forall i=1,2,\cdots,p$. This follows from step 1.
$\quad\quad$ ii) Second, for each set $X_i$, the largest integer in each sequence of consecutive integers in $X_i$ always belongs to $Y_i$.
$\quad\quad$ iii) Third, $Y_i \cap X_j=\varnothing$ for all $i \neq j$. Indeed,
\begin{align*}
Y_i \cap X_j &= \{x \mid x \in (Y_i \cap (X_j \setminus I))\} \cup \{x \mid x \in (Y_i \cap (X_j \cap I))\} \\
& \subseteq \{x \mid x \in (Y_i \cap Y_j)\} \cup \{x \mid x \in (Y_i \cap I)\} \\
&=\varnothing.
\end{align*}
For convenience in the following argument, we call $y_{i,j}$ (for $j=1,2,\cdots,t$) the generating element of the elements $x_{j,i_h}$ less than $y_{i,j}$.
We see that:
$\quad$ a) $X_i \neq \varnothing, \forall i \in I$. According to step 1,
$$\varnothing \neq Y_i \subseteq X_i.$$
$\quad$ b) $\bigcup_{i=1}^p X_i = [n+1]$. Indeed, $\bigcup_{i=1}^p X_i \subseteq [n+1]$ is obvious. Consider $z \in [n+1]$. Then:
$\quad\quad$ i) For $z \not \in I$. Since $\beta \in D_{n+1-m}$, there exists a unique $j$ such that $z \in Y_j$. According to step 1, we have $z \in X_j \subset \bigcup_{i=1}^p X_i.$
$\quad\quad$ ii) For $z \in I$. Let $y \in [n+1] \setminus I$ be the smallest element that is greater than $z$ (this element always exists because the elements in $I$ are at most $n$). Suppose $y \in Y_j$. According to step 3, $y$ is the generating element of $z$, meaning $z \in X_j \subset \bigcup_{i=1}^p X_i.$
In summary, $ \bigcup_{i \in I} X_i \subseteq [n+1] \subseteq \bigcup_{i \in I} X_i,$ meaning $\bigcup_{i \in I} X_i = [n+1]$.
$\quad$ c) $X_i \cap X_j = \varnothing, \forall i \neq j$. Using the third observation, we have
\begin{align*}
X_i \cap X_j &= ((X_i \setminus I) \cup (X_i \cap I)) \cap X_j \\
&= (Y_i \cup (X_i \cap I)) \cap X_j \\
&= (Y_i \cap X_j) \cup (X_i \cap I \cap X_j) \\
&= X_i \cap X_j \cap I.
\end{align*}
This means that if $X_i$ and $X_j$ intersect, the common element must belong to $I$. Suppose $X_i \cap X_j \neq \varnothing$, consider $z \in (X_i \cap X_j)$, let the generating element of $z$ in $X_i$ be $y_{i,s} \in Y_i$; the generating element of $z$ in $X_j$ be $y_{j,v} \in Y_j$. Without loss of generality, assume $y_{i,s} < y_{j,v}$. It follows that $y_{i,s}$ is a natural number in the interval $[z, y_{j,v}]$. According to step 3, $y_{i,s} \in X_j$. This implies $Y_i \cap X_j \neq \varnothing$. This contradicts the third observation.
$\quad$ d) For each set $X_i$, when $X_i \cap I \neq \varnothing$, we need to prove that for each $x \in X_i \cap I$, $x+1$ also belongs to $X_i$. Indeed, suppose $x+1 \not \in X_i$, which means $x$ is the largest natural number in some sequence of consecutive natural numbers in $X_i$. It follows that $x \in Y_i = X_i \setminus I$ (according to the second observation). Thus,
$$x \in ((X_i \cap I) \cap (X_i \setminus I)) = \varnothing.$$
This is impossible.
In summary, $\alpha = \{X_1;X_2;\cdots;X_p\} \in C_I$.
According to the definition of the mapping $f$, we have
$$f(\alpha) = \beta.$$
At this point, we can affirm that $f$ is a bijection. Therefore, we have
$$\left|\bigcap_{i \in I} A_i \right| = B_{n+1-|I|}.$$
In other words,
\begin{align*}
a_n &= B_{n+1} + \sum_{\varnothing \neq I \subseteq [n]} (-1)^{|I|} \left| \bigcap_{i \in I} A_i \right| \\
&= B_{n+1} + \sum_{m=1}^{n} (-1)^{m} \binom{n}{m} B_{n-m+1} \\
&= \sum_{m=0}^{n} (-1)^{m} \binom{n}{n-m} B_{n-m+1} \\
&= \sum_{m=0}^{n} (-1)^{n-(n-m)} \binom{n}{n-m} B_{n-m+1} \\
&= \sum_{l=0}^{n} (-1)^{n-l} \binom{n}{l} B_{l+1} \\
&= B_n \quad \textrm{(according to $(\star)$)}
\end{align*}
The problem is thus solved.