As people above mentioned, self-discipline can certainly be part of it.
For me, I fast for a few reasons. One is to come closer to God. I’m putting my body second and God first, and he respects that and often responds to my prayers more swiftly and dramatically during that period. I might fast as a form of praying. I might do it for increased intimacy with God or in order to have some prayer answered. It again puts my body second and my God first, which he respects and which can increase the potency of prayer.
My Lent fast is a gift to God, a way in which I can show him how I love him. I put him before my body, which shows him that I care. It is a gift of love. It also, to me, symbolically represents putting God before the world in my life.