Primary reason is your flexibility and poor mobility in spine.
Disc between the two bones in spine has a special hydrophillic {water absorbing} property when it is not loaded to much. During night spine stays relaxed so disc absorbs more water, as the disc{swollen Ballon} are stacked between two bones of spine ,beacuse of increased water content spine is pushed to bit elongated state, which your joints in spine ,muscles surrounding spine , covering of muscles (Fascia) are not allowing because of poor flexibility and mobility. That is why you feel pain in back . Within few minutes of body load and movement water moves out you feel relaxed
Next Steps
Go for a manual therapy session and get your flexibility checked by a physio
Health Tips
Learn flexibility and mobility exercise from a physio