Typically, scarf patterns have a 3-5st "edging" or "border" at each end of the row, especially when the scarf might have some st st in the body.
Stockinette Stitch is notorious for 'rolling' in onto itself. For sweaters this doesn't matter much cuz the edges will be seamed later.
A good 5-st edging/border for a scarf is "seed stitch".
That is to say: K1P1K1P1K1 on the right side; on the wrong side, purl the knits and knit the purls.
Here is a scarf that even though it has 'patterning', it is still mainly st st on the surface. Without the 5st borders on each side, this scarf would have rolled, too!
Notice the wires that I've inserted into the the very end
stitches? These are 'blocking wires' and they are very
useful for blocking scarves!
Below is another scarf that has mainly st st for the body, but notice how it does have 'borders' at each end? The main purpose is to prevent the st st from rolling. The borders also add artistic elements.
Here's another scarf with seed stitch borders:
BTW, these are all free patterns.