Why do I keep getting muscle spasms in my neck and how can I stop it?

See orthopedist. Neck pain commonly is due to muscle spasms, poor posture, arthritis, herniated disks etc. If you are symptomatic in your neck and back then seek an orthopedic surgeon or preferably an orthopedic spine surgeon. They can prescribe medications and therapy that can help your symptoms.