Why does the back hurt when doing sit ups?

It is not uncommon to experience pain when doing sit ups. Because sit ups engage the hip flexor muscles more than other exercises. It can be quite common that the hip flexor muscles through overworking and over tightening create a pull on the lumbar vertebrae, which can lead to discomfort.
Often sit ups are performed on a hard surface outside or on the floor. This can create discomfort, because the spine encounters a hard surface during workout and this in return gradually lets one changes one’s exercise position.
When feeling discomfort during exercises, the body will unconsciously readjust itself to reduce discomfort. This can lead to performing exercises in a harmful position that over time will overstretch or injure other segments of the back.
Therefore it is advisable, when feeling pain with any exercise especially sit ups, to choose one’s exercise site carefully.
Instead of working out on the ground, one can use a yoga or fitness mat to protect the back and to make sure that the intended exercise is performed correctly.
Sometimes the pain,while performing sit ups is related to unbalanced trained muscle areas. If one continuously experiences pain while performing sit ups, one should first skip sit ups and perform other workouts that strengthen needed muscle areas and at a later time try to return to sit ups.
Alternative exercises can be:
Front Plank
Side Plank
Glute bridge