What is decision tree pruning and how does it impact model performance?

I was trying to train a Decision Tree model on my dataset but it is showing ambiguous results, I explored this error and found that it can be related to the concept of overfitting which occurs when the data is too large and complex, and my dataset is both. Can anyone tell me why this happened? And what can I do to prevent overfitting in decision trees? Please give example codes too for preventing this from happening, I have given some codes below in which I have loaded a dataset, split it into training and testing sets and I have initialized a decision tree model in the same way I did for my dataset, you can continue on with the code and provide techniques for prevention of overfitting.

Loading the dataset:

Splitting the dataset into training and testing sets:

Creating a decision tree model: