1. Don't panic!
Not everyone has had the experience of witnessing or having a panic attack, and honestly, it can be pretty hard to see. Although your natural instinct may be to panic as well because you don't know what to do, the most important thing you can do for someone in this state remains calm and be an anchor for them to stay grounded.
Take a step back and take a deep breath to find your cool, then you can help them find theirs. When someone is panicking the best thing you can do is be calm for them. Ways to do this are by talking in a calmer and slower voice than normal and be gentle with them.
2. Ask/listen to what they want.
While there are general things that seem to be beneficial to most people, everyone is different and one person may not want you to do certain things that might help another person. For example, while one person would find comfort in a hug during this time, another person may prefer having space to themselves. If you would like to try to help someone and have a way to do so, simply asking "would it help if I ____" or "could I ____" is not a bad thing to do.
Understand that even if you ask this person a question, they might not answer, and that is okay. Although an answer may feel urgent, give the person time to try to answer and if they still don't then go with your instincts of what feels right.
3. Help them breathe.
When having a panic attack, one of the person's biggest issues is trying to breathe. There are many different breathing techniques that people recommend, and talking the person through any of these that feel right can make it easier for them.
Tell the person to take a long, deep, slow breath in through their nose, hold in the air, then release the air from their mouth like they are blowing on something. When I walk a person through these steps, I try to do it with them as I direct them in order to help them find a steady pace.
4. Take their mind off of what is going on.
This can be done in many ways, but mostly talking about positive or funny things that will make the situation more lighthearted will help take them out of their panic. Whether it is reflecting on good memories between you and that person or telling them an embarrassing childhood story, anything that can make them think about something other than the fact that they don't feel well is important to hear.
If you do not know the person very well, a good way to approach this is by asking them questions about themselves that are simple enough for them to be able to answer but make them think about something else.
5. Give them reassurance.
When having a panic attack, it often feels like the actual end of the world. As simple as it may sound, reassurance that those feelings are only temporary and that everything will be okay will go a long way. It is important to show your full support for this person and let them know that there is nothing wrong with them for feeling this way, and that you want to be helping them because they deserve to feel better, not because you have to.
Sometimes you may feel helpless or confused in a situation when you are trying to be there for someone and your actions don't have an immediate/obvious effect, but just keep in mind that this person does not want to feel this way and probably is even self conscious about how it affects other people. If you really want to help this person, you will remind yourself that everything will be okay, then remind the person panicking that everything will be okay too.