how to prevent - be careful and keep them out of the tank (this is tougher than it sounds)
Get rid of once you already have it - you have several options depending on what you are willing to do. You probably will never get rid of it completely.
You can try doing it manually by hand - if you have a couple this is easy, if you have hundreds or thousands this is tough, time consuming and can cause it to spread more.
You can try to find a copperband butterfly - but they can be hard to get acclimated and eating. If you luck out and get a good specimen he will eat all the ones he can get too.
Berghia nudibranchs - takes a while, expensive, can be hard to find, will starve to death once they can't eat all the ones they can access. They ONLY eat aiptasia but it can be challenging to get a colony established in your tank. They also take a while to make a noticeable change - a month or more.
Peppermint shrimp - work well if you get the right ones and they can get to it.
Filefish - might work might not. Mine won't touch the stuff.
Laser - BE CAREFUL, they're dangerous and can cause harm to you, your family and your fish if you are careless.
Tear the whole tank down and start over (I don't condone this BTW).
Ultimately it can be VERY difficult to prevent aiptasia and if it gets away from you can be hard to fix. Once you have it in your system it's doubtful you'll ever get rid of them 100%. They love to hide in your sump, plumbing, overflows etc.