Fix $(a_n \mid n < \omega)$, $(x_n \mid n < \omega)$ such that $x_n \in E_{a_n}$ for all $n < \omega$. Without loss of generality we may assume
- $\{\xi\} \in \{a_n \mid n < \omega \}$ for all $\xi \in \bigcup \{a_n \mid n < \omega\}$ and
- $a,b \in \{a_n \mid n < \omega\} \implies a \cup b \in \{a_n \mid n < \omega \}$.
(Otherwise close the sequence $(a_n \mid n < \omega)$ under these operations and add dummy values for the corresponding $x$'s.)
Consider the set $T$ of all functions
$$
t \colon \{a_0, \ldots, a_{n-1} \} \to [\kappa]^{< \omega}
$$
such that
- $\forall i < n \colon t(a_i) \in x_i$ (in particular $\mathrm{card}(t(a_i)) = \mathrm{card}(a_i)$),
- $\forall i < j < n \colon a_i \cup a_j \in \{ a_0, \ldots, a_{n-1} \} \implies t(a_i \cup a_j) || a_i = t(a_i)$.
The operation $||$ is defined as follows: Let $a \subseteq b$, $B$ be finite sets of ordinals such that $\mathrm{card}(b) = \mathrm{card}(B)$. Write $b = \{b_1 < \ldots < b_k\}$ and $B = \{B_1 < \ldots < B_k \}$. Let
$$
\pi \colon \mathrm{card}(a) \to b
$$
be the unique $<$-preserving function such that $a = \pi " \mathrm{card}(a)$. Then
$$
B ||a := \{ B_{\pi(0)} < \ldots < B_{\pi(\mathrm{card}(a)-1)} \}.
$$
$B || a \subseteq B$ is the subset of $B$ of those elements that correspond to the indexes of $a$'s elements in the increasing enumeration of $b$.
Now consider the tree $(T; \subset)$.
Claim. $(T; \subset)$ is ill-founded.
Proof. Consider $j((T; \subset))$. Since $T$ is countable, elementarity yields that
$$
j((T; \subset)) = (j " T; \subset)
$$
and
$$
j " T = \{ j(t) \colon \{ j(a_0), \ldots, j(a_{n-1}) \} \to [j(\kappa)]^{< \omega} \mid j(t)(j(a_i)) \in j(x_i) \wedge \ldots \}.
$$
In $V$ consider
$$
b \colon \{ j(a_n) \mid n < \omega \} \to [j(\kappa)]^{< \omega}
$$
given by $b(j(a_i)) := a_i$. I'll leave it to you to check that $b \restriction \{j(a_0), \ldots, j(a_{n-1}) \} \in j " T$ for all $n < \omega$ so that
$$
V \models (j " T; \subset) \text{ is ill-founded}.
$$
By absoluteness of wellfoundedness we have that
$$
N \models j((T; \subset)) = (j"T; \subset) \text{ is ill-founded}
$$
and hence, by elementarity, that
$$
M \models (T; \subset) \text{ is ill-founded}.
$$
For the rest of this answer, work in $M$. Let
$$
b \colon \{a_n \mid n < \omega \} \to [\kappa]^{< \omega}
$$
be a branch through $(T; \subset)$. We define
$$
f \colon \bigcup \{a_n \mid n < \omega \} \to \kappa, \xi \mapsto \bigcup b(\{\xi \}) = \text{ the unique element of } b(\{ \xi \}).
$$
(This is possible by our assumption 1. on the sequence $(a_n \mid n < \omega)$.)
Claim. $f$ is as desired.
Proof. Let $a_n = \{\xi_0 < \ldots < \xi_k \}$. Then
$$
\begin{align*}
f " a_n &= \{ f(\xi_0), \ldots f(\xi_k) \} \\
&= \{ \bigcup b(\{\xi_0\}) , \ldots, \bigcup b (\{\xi_k \}) \} \\
& = \{ \bigcup b(a_n) || \{\xi_0 \}, \ldots, \bigcup b(a_n) || \{\xi_k\} \} \\
&= b(a_n) \in x_n.
\end{align*}
$$
Q.E.D.