This is one of the big mysteries of knitting that can be quite frustrating for beginning knitters. But the answer to why stockinette stitch curls is really not that mysterious at all.
Stockinette stitch curls because of basic differences between the knit stitch and the purl stitch. Knit stitches are a little bit shorter and narrower than purl stitches.
When you're working a pattern that has knits and purls on both sides, this difference in stitch size doesn't really matter, but when you're working in stockinette stitch, where all the knit stitches are on one side of the work, the knitting tends to curl.
Some patterns use the fact that stockinette stitch curls as part of the design, such as rolled-brim hats or sweaters with rolled hems.
If you want to use stockinette stitch but don't want to deal with the curling, add some other kind of stitch to the edges to keep them from curling. Ribbing is often used for this purpose on sweaters, or you can add a few stitches of garter stitch to the sides of a pattern knit in stockinette stitch.
Or you can try a pattern where the curling doesn't matter so much like the Fun Fur Knit Scarf, which is reminiscent of a feather boa and doesn't need straight sides to be cute.