This most often occurs as a result of an injury. Something like a whiplash injury from a fall, sports injury or a car accident. It can also be from sleeping in an awkward position or being in one position too long. Even an injury to your shoulder or turning too quick can do it. There's actually many ways someone can strain a muscle; sometimes it can literally be from stress or that combined with one of the other things I've mentioned.
2) Herniated or Bulged Disc
A Herniated disc occurs when the inner disc, the nucleus, protrudes or ruptures through the outer part and puts pressure on a nerve or nerves. It usually occurs as a result of a very serious injury, like one of the above but on a more serious scale. Most often someone has accumulated a certain amount of wear and tear first then something is the "final straw" causing that disc to rupture.
A bulge is similar except the outer disc stays intact but bulges. The same pain and inflammation may result. Depending on exactly where the disc bulge is and its size will determine the amount of nerve pressure. Often as discs degenerate and flatten they bulge. This leads me to my next common cause...
Arthritis is another word for degeneration or wear and tear. People who beat up their bodies more over the years will have more arthritis as they age. There are actually many factors, but basically people who don't take care of themselves usually break down faster. Just like a car, if you don't feed it with good fuel and maintain it by changing the oil and cleaning certain things it may stop running. Our bodies are the same way and as more degeneration sets in the bones become more brittle, muscles become tighter, and pain increases. Constant repetition of certain activities or having poor posture overtime can lead to degenerative changes in the spine.
4) Muscle Spasm
Muscles are an important factor in allowing us to move, and to be active. Doing one motion incorrectly, or repetitively can cause the muscles to overstretch and be injured. Muscle spasm can cause constant pain because the muscles are irritated and pressure on nerves. Remember those muscles are attached to the spinal bones and call force misalignments which also put pressure on the nerves. Misalignments can cause poor posture or the reverse.
5) Poor Neck Posture
What your posture looks like on the outside is often what your spine looks like on the inside. So if you have forward head posture for example, most likely you've lost the normal neck curvature. This is also known as loss of cervical lordosis or "military neck". This will tension the spinal cord and nerves; it will strain the muscles in the back of the neck and predispose you for all of the conditions mentioned above.
Now, onto how to prevent and fix these common cause of Neck Pain...
The best way to prevent and correct all of the above is to keep the spine in it's best alignment. Injuries and strains will happen but when they do, they will be less and the muscles will heal much quicker. My best recommendations to avoid and end your neck pain are to see your chiropractor when an injury occurs, avoid repetitive stress to the neck, and try to maintain good neck posture. I realize sometimes you can't get to your chiropractor's office soon enough, or you find it difficult sometimes to maintain good posture. In this case I would also recommend using a good neck pillow. The traction pillow will help correct and maintain alignment while you sleep. This is central to keeping pressure off of the nerves and therefore preventing muscle spasm, degeneration, and disc injury.