I have anxiety too and mine comes and goes as well. I have no idea what will set me off or when. I can go months without anything happening. I do have pills that will calm me down if i can't get calmed down but i don't have to take them very much. These are somethings I do to try and calm down before using the pill:
-play music (try different kinds then the normal stuff you listen too, I prefer country for my every day listening but to help with anxiety I find hard rock works)
-talk to someone (I have three people that I can call, my mom, grandmother and best girl friend. They all know about my anxiety so that helps but I just call them up and tell them I am having a hard time calming down and just talk to them. They are all use to it now so they know just to talk about anything, just as long as it getting me to focus on something else.)
-play with my pets (I got my Claire for that very reason. It was suggested to me to get a pet, that it might help. It worked so well I get Emma not even a full year later. Both dogs)
-this can be a hard one for some but try reading a novel. A comic book or the new paper might work too but I find novels work the best.
The main thing I find with all of these things is that they get me to think and FOCUS on something other then myself.
As for trying to preventing an attack, that is a bit harder. I just try to keep myself happy. Even the little things can do the trick. Like going to see a movie or coffee with a friend. I find my dogs help lot but I am very much a dog person. Mostly its up to you. It does take time and a lot of trial and error to find what works for you and most of all don't be afraid to try! My fave saying in life is it never hurts to try (or ask). Just don't give up because it does get better. I have had the problem most of my life but never knew what was wrong until I was 20. I am 25 now and just really getting a hang of it all.But now everything is going good. :)