Catapults were used in medieval times to launch a siege on a castle and try to take it over. They were used to break down walls so that people could enter and try to push the defenders back to their castle and hopefully take over the castle. But the catapult is just a general idea, there are many different types of catapults and each one has different uses in warfare.
The main type of catapult they use is called a slingshot catapult, they use it a lot because it can shoot very far and it shoots large rocks at the wall to do a lot of damage, so they can basically do a lot of damage to the wall. from a safe distance. Those who defended the castle normally could not reach the catapults because to reach them they had to go through the army in front of the catapults that defended them, so it was out of the picture to try to shoot them down.
Another type of catapult (something like a catapult that still launched large objects) was the ballista, this catapult I guess I could call it did not launch large rocks but was basically a large bow that launched large arrows but in the form of a catapult. This was not used too much due to trying to make the arrows I shot, it was easier to use just a normal catapult because there were rocks everywhere. But even though they were rare, they were still used sometimes due to the precision they had, they could almost always hit the target.
In addition to those two types of catapults, they used another type of catapult called a trebuchet catapult. It’s like the slingshot catapult, but it wasn’t the most accurate catapult they had. It was very unreliable to try to hit a specific location in the castle. So they used it just to throw stones at the castle to try to hurt the people inside the walls. If possible, they may be lucky enough to crash into a wall and help knock it down to get inside and attempt victory. Even with these three types of catapults shooting at the wall (if they have all of them when they do a siege), going in would be weird if they won due to the defense of the castle, and people waiting to defend themselves when people rush through the hole in the castle walls.