Because the swingarm is at an angle relative to the ground, the wheel's driving force at the axle causes the suspension to extend for the anti-squat effect. You can see this by putting your bike's front tire against a curb or wall and (carefully!) applying some power to the rear wheel; the bike's rear end will rise slightly. With more swingarm angle, there is more anti-squat tendency.
The chain, pulling on the rear sprocket, likewise causes the suspension to extend. This is a bit more difficult to see for yourself, but Gaetano Cocco, in his book "How and Why: Motorcycle Design and Technology," describes supporting the bike on a frame stand, removing the rear shock and using a bungee cord to support the rear wheel off the ground. With the bike in gear, an application of throttle will cause the rear suspension to extend. The closer the chain is to the swingarm pivot, or the greater the chain's angle with respect to the swingarm, the more its force is translated to extend the suspension.
The combination of these two forces - driving force and chain pull - offsets a portion of the weight transfer due to acceleration that is working to compress the suspension. There are several ways to express the relationship, but I typically use a percentage value. For example, 80 percent anti-squat indicates that the combined extension forces offset 80 percent of the compression forces from weight transfer. Note that with more acceleration and increased weight transfer acting to compress the rear suspension, thrust and chain force - extending the suspension - also increase. For the most part, a nice balance is retained and the anti-squat value is consistent given any amount of acceleration.
There is a lot of math and measuring involved, but there are three basic ways to increase the anti-squat tendency: raise the rear of the bike (or the whole bike) to increase swingarm angle; use shorter gearing to change the angle and position of the chain relative to the swingarm; or raise the swingarm pivot itself.
One common misconception is that switching to smaller or larger sprockets but keeping the same gearing ratio will increase or decrease anti-squat. However, the math (and practical experience) shows that if the gearing ratio is the same, anti-squat is affected only minimally. Smaller sprockets will put the chain closer to the swingarm for more anti-squat but at the same time the chain angle has decreased, reducing anti-squat almost the same amount.
In a perfect world, the amount of anti-squat designed into your motorcycle would suit all conditions and you wouldn't have to worry about it. Unfortunately, there are a couple of additional variables that make this a parameter requiring almost constant attention. First, as the suspension compresses, the swingarm and chain angles decrease and the anti-squat value typically decreases. If the swingarm angle goes negative, thrust will work to continue compressing the suspension rather than extending it. Second, because aerodynamic forces come into play at higher speeds, the motorcycle does not accelerate as much and there is less weight transfer, even though the thrust and chain force remain. That nice balance of weight transfer and anti-squat forces changes with speed. These variables mean the optimum anti-squat value is difficult to achieve even given an unchanging set of conditions, and is a constantly changing objective.
Anti-squat is so important on a powerful bike that teams at the World Superbike and MotoGP level will change primary gearing inside the engine rather than final gearing for fear of upsetting that delicate balance, but you can see the difficulty: Find the best anti-squat for traction and handling to suit one set of conditions or a particular track, and you may have to start all over again at a different track or if you alter suspension, geometry or gearing for changing conditions.