Triangle pattern scarf folding in the middle

It sounds like you are doing stocking stitch? Knit 1 row, purl 1 row.
If so, that worked by itself will always curl/fold. You are doing nothing wrong. It’s the nature of the stitch.
See this thread.
http://www.knittinghelp.com/knitting/forum/showthread.php?t=32810
It needs to be combined with something else.
Usually a border, e.g. approx 5 sts or more of garter st, seed st, ribbing.
or Seamed to another section (in Garment), or to itself by folding
(scarf) or adding lining.
If you scan through various types of patterns you might notice not many are done in stocking stitch alone.
they either are in a different stitch pattern, or have a border of some sort.