It usually happens when the plant is "stretching" for more light or if the pot is too wide, making the leaves sag. Try moving it to a sunnier spot and check out this guide on
How to Grow Aloe Vera Plant for tips on the right soil and light balance to keep it upright.