How to use a NN for seq2seq tasks?
I think you meant pattern recognition instead of pattern matching in you question. Because pattern matching has nothing to do with NNs as far as I know. So RNNs is the easiest architecture you could use for this task. Have a look at this post. http://karpathy.github.io/2015/05/21/rnn-effectiveness/
It's long, but it's very well written and explains why RNNs work well with sequential data. In brief RNNs accumulate information about what was fed in them previously and store it in the hidden state vector. That information is a summary of a sequence which helps it to predict the output sequence. RNNs can be applied to variable length input and catch dependencies among different parts of the input (as opposed to dense layers that can be applied to a sequence only point-wise).
Here's how exactly you can apply reccurent layers (https://www.tensorflow.org/guide/keras/rnn, https://pytorch.org/docs/stable/generated/torch.nn.RNN.html).
There are more advanced architectures like LSTMs. Also you can try transformers (http://jalammar.github.io/illustrated-transformer/) which use attention mechanism (https://lilianweng.github.io/lil-log/2018/06/24/attention-attention.html).