Gymnastics has been rated one of the toughest sports in the world, and along with that comes the factor of injuries; gymnasts are subject to injuries almost as frequently as football players!
While injuries and accidents are bound to happen and can not be avoided altogether, there are precautions you can take to minimize the risk. These precautions come in forms of mental/body awareness, sufficient muscle strength, and clear communication.
The most important safety rule is to know what you are doing. Never blindly attempt a trick you are not familiar with. You should understand the basic mechanics of the skill, and know what to do in case something goes wrong. If the trick doesn't go as planned, your body should immediately respond in a safe way for you to "bail out."
Another related rule is that you should know where and how your body is oriented throughout the skill. If you are twisting, you should be able to "sense" how far you have twisted, and if you are flipping, you should know how much you have rotated. This awareness should keep you alert, so that in case something doesn't go as planned, you have time to land safely.
Many injuries happen because one or more sets of muscles are not strong enough to support the stress that the joints take. The most common example of this is twisted/sprained ankles. There are small, but essential muscles that run from your calf down to your foot, and when they are not strong enough, you will find that "turning your ankle" occurs frequently. For this and many other recurring injuries, conditioning targeting those weak muscles can lessen the likelihood of them happening.
Last, but not least, is the importance of open communication and understanding between you, your coach, and your teammates. It should always be clear between everyone involved about what you are being asked to do. If your coach expects you to do a particular skill, but you misunderstand and do something different, your coach may not spot you correctly. Similarly, you should know what your teammates and other gymnasts around you are doing. Collisions and other accidental impacts can be serious if you are not aware of what someone else is doing.
Of course, there are many other items of safety precautions to take into consideration. These include:
Safety precautions are important not only in gymnastics, but in other sports and in everyday life, too. Making common practice of these rules will make it safe, not only for you, but for everyone else around you.