You could've strained your back muscles or even strained your spine when doing something such as lifting something using the wrong lifting technique.
Having an injury to the discs that support your spine could also be a cause of spine and back pain when standing up straight.
If your spine continues to hurt and you're unable to stand up straight I would recommend making an appointment with your doctor to have them take X-Rays and get your spine checked out.
If could also be that your spine is misaligned due to an injury etc.