Your question:
Let $f_n:X\rightarrow \mathbb{C}$ be a sequence of measurable functions such that $f_n\rightarrow f$ in measure.
Let $f_{n_k}$ be a subsequence of $f_n$ such that $f_{n_k}\rightarrow g$ pointwise a.e.. Then, is it necessary that $f=g$ a.e.?What would be a counterexample?
The answer is YES. It is true that $f=g\:$ a.e..
First, note that a standard result in Measure Theory says:
If $f_n:X\rightarrow \mathbb{C}$ is a sequence of measurable functions such that $f_n\rightarrow f$ in measure, then there is $f_{n_k}$, a subsequence of $f_n$, such that $f_{n_k}\rightarrow f$ pointwise a.e..
(See, for instance, Royden's Real Analysis, fourth edition, section 5.2, page 100, Theorem 4)
In your question:
Since $f_n$ converges in measure to $f$ and $f_{n_k}$ is a subsequence of ${f_n}$, we have that $f_{n_k}$ also converges in measure to $f$, and so, by the abovementioned result, there is a subsequence $f_{n_{k_j}} $ of $f_{n_k}$ which converges to $f$ pointwise a.e. .
Since $f_{n_k}$ converges to $g$ pointwise a.e. and
$f_{n_{k_j}} $ is a subsequence of $f_{n_k}$, we have that $f_{n_{k_j}} $ also converges to $g$ pointwise a.e. to $g$.
So, $f_{n_{k_j}}$ converges to $f$ pointwise a.e. and $f_{n_{k_j}} $ also converges to $g$ pointwise a.e.. So $f=g\:$ a.e..