There are three basic ways to avoid sacks.
First - You can do it with play calling. If you want to pass you can throw quick passes that get the ball in and out of the QB’s hand so fast that it is nearly impossible to give up a sack. You can also just take the service academy approach (or the old Georgia Southern approach) and run an option offense where you hardly throw the ball. Most sacks in the NFL took longer than 2.5 seconds in the 2023 season. There were four starting QBs in 2023 that got the ball out of their hands in less than 2.