My question is where would you usually keep a catapult on a battlefield. It feels as if you shouldn't keep it in the rear back of the army since it won't reach the target, and also you want to have as much backward mobility to reinforce where there are weaker parts of the army. Don't you have it in the middle of the army instead? And when you defend a castle with catapults outside and an army. Should it be the second line after the cavalary, or have the catapults next to the wall. Any explanation would be great.
What was the place of a catapult in a formation
Typically they weren't deployed along with infantry. Catapults were siege weapons which would be used against standing fortifications over hours or even days to attrit fortified towns and their defenses. The infantry didn't need to be standing by all that time, just at the end when the defenses were down at which time they would likely be standing behind or between the catapults.
Mostly the catapult were siege weapons, used against standing fortifications and not against troops in the field as your question suggests. Lots of men who weren't otherwise contributing to defending themselves or the army, and would be vulnerable if attacked on the ground would be a significant liability. Also the weapons were generally unsuited for infantry warfare except in very specialized circumstances. For these reasons using Siege weapons in a pitched battle against infantry was rarely done and seen as more of a liability, especially prior to the counterbalance was introduced.
For the counter balanced trebuchet, it reduced the number of men it took to operate the siege engine but increased the reload time and thus reduced the overall rate of fire. Throwing a fifty pound rock 350 meters to take out a few foot solders every five minutes isn't really and effective use of the weapon which probable requires as many men to operate even at the reduced counter balance number than it would hope to harm on the receiving end. They were thus most effective, against the walls of some fortification or an enclosed enemy like inside a city, which it could level over many iterations over a prolonged period of time.
The exception to this would be Alexander the great who was one of the first to use his siege weapons in the field against troops. The Macedon's were masters of combined troop tactics, and to them their siege engines were just another specialized component to their army. Alexander used his siege weapons to throw stones across a river to clear the river of enemy soldiers to allow his forces to cross at a battle against the Scythians.
Macedonian Army Alexander the Great appears to have been one of the first generals to employ artillery on the open field of battle, rather than in a siege. He used massed artillery to fire across a river at a Scythian army, causing it to vacate the opposite river bank, thus allowing the Macedonian troops to cross and form a bridgehead.
There is almost no evidence of a catapult used in battlefield. They were used in the sieges. See Greek and Roman artillery in Wikipedia.