In this article, you will know how ChatGPT Works.
https://www.scalablepath.com/data-science/chatgpt-architecture-explained
Note that Neural Network is a model of AI mechanism which firstly must be trained. Train means you will give some prepared questions and answers and it will learn and train via these inputs and outputs. So after training, this model will answer the questions it will previously learnt.
So ChatGPT have learnt much more data previously. so it can answer rare questions easily.