It's a wise step to develop a toolbox of coping mechanisms before you need to use them. In fact, the best time to practice using relaxation and grounding tools, which I'll share below, is when you are somewhat anxious, but not in a full-blown panic attack. You will start to notice how you can regulate your anxiety when it's manageable so that when you have a panic attack, it will become more and more natural to use these techniques.
There is an increasing body of science that shows anxiety and panic are intricately related to our respiration (breathing). Some even say that panic attacks happen because something triggers our brain to think we are getting enough oxygen. With this said, making a habit of taking breaks through the day to notice and adjust your breathing can help to prevent and teach how to breathe during a panic attack. Most watches now have Breathe apps that can remind you to breathe deeply during the day. I've attached a link to some breathing exercises at the bottom.
Reducing stress and/or deliberately paying attention to times during the day and tasks that raise our stress is also helpful. When we feel stress, we tend to tense our muscles, clench teeth and often breathe more shallowly. This can trigger the brain to think it isn't getting enough oxygen, which could lead to a panic attack. To combat this, the breathing exercises throughout the day can help, as can what's called progressive muscle relaxation. I've attached a link to this exercise below.
Now, your primary concern is what to do in the moment. We've covered some things you can do to possibly prevent panic attacks or lower their occurrences, but if you are in a panic attack, you can try using some of the breathing exercises, but you can also try grounding exercises. Grounding exercises help you detach from emotional pain by getting you more in tune with your environment and less focused on your internal experience. These also function as "self-talk" exercises.
Some ideas here include:
Counting backwards by 3's or 7's from 100 or 200
54321 exercise: find 5 things you can see, 4 things you can touch - noticing your feet on the floor can be very effective, 3 things you can hear, 2 things you can smell, and 1 thing you can taste.
You could even create your own list of things to recall or recite. For example, name as many countries as you can, or write down how many foods you can think of that start with the letter A...you get the idea!
I hope you find some of these helpful. If you still find the panic attacks are troubling you and you start to avoid going out because of fear of the panic attacks, it is a good idea to reach out for some extra help such as therapy or an appointment with your primary care doctor.