The 4 stitches on the end can be a border (that looks different, for example), but sometimes they are just necessary over all.
6 stitches plus 4 does not say that the 4 stitches are all worked at the same end of the row. Most likely (but look in your pattern) this is 2 in front and 2 in the back.
Some patterns need a border or look better with it.
Sometimes the design calls for that.
Sometimes the stitches are needed for the edge making, sometimes for sewing stuff up.
In some patterns, especially lace, the repeat can not (or not well) be worked at the beginning and / or end of a row (imagine a yo on the beginning / end... that is not usually nice to work (but possible) and will not look good in most cases.
Therefore a lot of patterns call for a number of stitches and a few more.
If you make your piece one repeat (of 6 stitches) of that pattern wide: 6 + 4=10 stitches.
But if you make it 6 repeats wide that is 6 x 6 = 36 and plus 4 that is 40 stitches.
That information is vital to shaping: if you make a scarf and the instructions would just tell you to co 40 stitches... well, just do that. But if you want to change the size, make it wider for example, then it would not help to do 45 stitches or 51, but you would have to add 6 or a multiple of 6 to keep the design going well.
If the stitches make the boder, sometimes it might say 2 + 6 + 2 (to show that 2 go on each end. or it might say any multiple of 6 plus 2 x 2. All the same reason.
That is all the magic.