You can almost guarantee this statement: Every single person will experience back pain at some point in their life.
The best prevention is prevention itself. To understand your body and make adjustments to your lifestyle in order to improve function and longevity.
Back pain in my experience comes by way of the following: Referred pain (originating from another area either through injury or imbalance but effecting the back), Genetics, Imbalance (Usually through repetition of movement through lifestyle choices causing the weakening of related muscles), Injury or accident.
In most cases, you can improve the health of your spine and back through exercise. This does not mean just lifting weights and doing cardio. Core related work, stretching, and targeting specific supporting muscles (depending on the issue) all play a part in combating back pain.
Ensuring you get adequate rest, keep hydrated, and make better food choices will assist. I am personally not a fan of relying on pain management medications simply because they can cause future health complications and generally mask the pain. They rarely fix the problem.
A thorough warm-up, balanced regular exercise routine followed by stretching after a workout while you cool down can be a huge preventative and rehabilitation component to combating back pain. By balanced exercise, I mean using all muscle groups throughout the workout week.
Focusing on the basics of exercise such as correct posture and breathing while keeping good form. Work on the core as opposed to just the abdominals. So Prone Holds instead of crunches.
Should a back issue occur either by injury, accident, or randomly your best bet is to head to a Dr for a preliminary examination and referral. Depending on the situation, you could be directed to a physical therapist, for a scan or just be told to rest. Consistent or frequently reoccurring issues should be taken seriously.