There are many reasons for back pain.
Most often there is lack of exercise for the back muscles resulting in poorly toned musculature which is a cause of poor posture and muscle spasms. Over time there is then degenerative joint disease and possibly herniation of disks as well as inflammatory changes. All of this can be most often treated with conservative measures and only occasionally is there a need for surgery.
If there is no improvement with NSAIDS (Non-Steroidal anti-inflammatories) and other non-opioid pain killers, then we use various injections and denervation techniques as well as physical therapy. Please check here(link).
However there is also a certain pattern of back pain which increases with walking and radiates into both legs, but can be improved with sitting and bending forward. This pattern is very suspicious for spinal stenosis (severe narrowing of the spinal canal). See animation below.
Finally, back pain with pain radiating into one leg and numbness in the heel or big toe is highly suspicious for sciatica which may be due to a lumbar disc herniation. See animation below.