Why does it hurt when I stand up after sitting?

Depend on what hurts. A person who has some pain when moving from a sitting position to a standing position can see a doctor for evaluation. Some people have arthritis in their joints, and hurt when joints move. Other people have recent injuries, which hurt if moved. Athletes can get overuse symptoms in the knees and back, which hurt if moved. Internal (chest, abdomen, pelvis) pain can be a problem with organs inside.
Most likely you have. A disc relatd problem in your lower back as you cannot transition load from sitting to standing. The disc is a weight bearing structure allowing for spinal movement. You need to focus on core exercises and exercise in general while avoiding weight gain as well as smoking. If the symptoms persist, see your doctor for evaluation.