There's one lesson that a very large number of knitters learn the hard way, fairly early in their knitting careers: stockinette curls. There's nothing quite like watching your laboriously produced scarf roll right up in a tube, is there? A fair number of knitters, however, learn this lesson like rote memorization, and don't really understand why it happens, or what if anything can be done about it. So let's take a look at the whys and wherefores of curling stockinette, and then just for grins, we'll look at why the springiness of ribbing is a related phenomenon.
These phenomena have their root in the shape of the knit stitch. Knit stitches are a little bit longer across their front faces than across their back faces in the horizontal direction, and a little bit longer across their backs than their fronts in the vertical direction. If you want a visual aid, take two pieces of paper that are the same size and shape, and cut a sliver off the top of one and the side of the other, and then tape them together along the edges, with the shorter and wider piece in front. See how the sides roll back, and the top and bottom roll forward? When you place a whole bunch of knit stitches together, that's how the resulting fabric wants to behave.
Stockinette is the fabric you get when the RS of your knitting is all knit stitches; if that statement doesn't make sense to you, you'd probably better look back at the post about knitting stitches as they appear, or perhaps the one about reading charts and how that relates to fabric. It aligns all the bigger front faces side-to-side, and all the bigger rear faces top-to-bottom, and it curls right up.
So, is there anything you can do about it? In a way, but to a certain extent this is an inherent property of the fabric, and so what you need to do is work with it or work around it, because you're not going to be able to make it go away.
One way to work around it is to substitute out a balanced fabric. This is a fabric where the distribution of knits and purls as viewed from the RS is fairly even, with about as many of one as the other. Some examples of balanced fabric are seed stitch, garter, and ribbing, and that's a reason that these are often used at the edges of a project. There are plenty of other choices for balanced fabrics, though, and a stitch dictionary that uses charts will make these easy to pick out. One source for these is the Walker Treasury Project -- this is a very laudable effort (in which you can yourself participate!) to produce nicely photographed color swatches of every stitch pattern in the Barbara Walker Treasury books, and to catalog them in ways that make them easy to find. Those patterns listed as being similar or the same on the wrong side will usually be balanced fabrics, since in order for it to look the same, it has to have the same stitches showing.
Another way to work around curling is to note that it only occurs on the free edges, and to eliminate those edges. For instance, you've probably not noticed horizontal curling on sweaters -- it's not that they're not curling, but that there's no unrestrained edge where the curling can manifest, so each stitch just flows placidly into its neighbor. If you want a stockinette scarf, one way to do it is to knit the scarf as a tube and then flatten it, so you've got a double thickness with stockinette on each side; it'll still curl at the ends, but you can seam those together and then they'll be restrained also.
What about just sort-of restraining the edge, as with a border? Well, that can have some success. I repeatedly see the suggestion to slip the first stitch on each row; I've never noted that as having any significant effect, but I can't stop you trying it for yourself. Adding a border of several stitches is somewhat more effective, but it's not a slam-dunk guarantee; a fabric that's strongly curling will just roll the border right into the middle of the tube. Here's a lovely example of a seed stitch border being totally overwhelmed, even though each side of the border is nearly a third as wide as the center of the scarf.
What about blocking? Again, it's of some limited utility. It works the best in wool, since wool has enough memory to hold a shape fairly well. It's more of a temporary solution, though, better for making something behave long enough to get your seams done than to make a scarf lay flat when worn; since the curl is an inherent property of the fabric, it'll eventually reassert itself. A possible exception is acrylic that's been "killed" with heat -- heated close to its melting point, so that a permanent change in the fiber shape is effected. This changes the entire character of the fabric, though, making it limp, and it's a permanent change, so it's not exactly the same as blocking, and often the change is not wholly desirable. It's definitely something that should be practiced on a swatch before applying it to a whole project.
One thing that does make a definite difference is that looser fabrics curl less. Tightly knitted fabrics have more energy, more tension in the stitches so that each acts more strongly on its neighbors. At one extreme, the scarf I showed above was knitted quite tightly for the yarns used, and that certainly contributed to the way it overwhelmed the border; at the other extreme, stockinette based lace, which is knitted exceedingly loosely for the yarn size, lies mostly flat, especially after blocking.
You may find success by combining several of these notions. For instance, a fairly loosely knitted scarf with a moderate seed-stitch or garter border, especially if it's made of wool and blocked, would probably lie fairly flat for a decent while, although you might need to periodically reblock.
Okay, so what's that I was saying about how ribbing is a related phenomenon? I did just mention that ribbing was one of the balanced fabrics, and it is. Ribbed fabric as a whole lays flat, and it doesn't curl up top to bottom at all, if it's a fairly even ribbing (knit ribs and purl ribs close to the same width). It does, however, draw in horizontally, and it does so in an elastic way, rebounding to at least some degree after being stretched out. It's this rebounding effect that's related to the curl of stockinette.
Ribbing is, fundamentally, adjacent strips of stockinette and reverse stockinette. What gives it its texture is the way these stitches act at the transitions -- the strips of stockinette want to curl backwards, while the strips of reverse stockinette want to curl forward, and they wrap around each other at the interface (I think of this as being like a lock seam in metal roofing, but this may prove nothing more than that I'm a geek in areas other than knitting, too). This gives you the texture with the knit ribs popping forward and the purl ribs receding, and it's also what gives you the elasticity, as the curl flattens out under tension and reasserts itself when tension is released.
This interaction helps explain why 2x2 ribbing is the most elastic for most knitters -- it gives the most scope for this interface to act on the stitches. In 1x1 ribbing, every stitch is trying to engage in this curling relationship on both sides, which sets up competing forces -- the same stitch is trying to curl to the right and to the left. In 2x2 ribbing, by contrast, every stitch has one side engaging in this, but the other is next to a stitch of the same type, in a relatively stable arrangement, so the curling side can curl as far as it wants to in just one direction. To go toward the other extreme, 3x3 ribbing has two-thirds of its stitches in this same type of relationship, but the center stitch of each strip is just sitting there, not trying hard to curl in either direction, so the fabric as a whole has less energy than the 2x2 ribbing has, and this tendency only increases as the ribbings get even wider. There are individual variance in stitch formation that can affect this, so there may be some knitters for whom a ribbing other than 2x2 (possibly one of the slightly unbalanced ones, like 2x1 or 2x3) is their stretchiest, but for most of us, that's the springiest.
The interaction theory also explains why corrugated ribbing (2-color, as discussed when we got deep into stranded knitting) is less elastic -- it's the curling between the columns that causes elasticity, and the stranding behind the purl columns pops them forward and doesn't let them recede as they would in a single color, nor let the knit stitches curl back as far as they'd like. This keeps it permanently somewhat flattened, and you lose a lot of the bounce.
The spring of ribbing, being a related phenomenon, can be affected by some of the same factors as curling. For instance, just as tight stockinette curls more, tight ribbing bounces more and pulls in more effectively. Blocking can also flatten it, and that's generally something you want to avoid when blocking items with ribbed edges -- either don't flatten it in the first place, or re-wet it after blocking the rest of the piece and scrunch it in nice and tight and let it dry that way.
I encourage you to play around with some swatches -- learn how the different factors affect the curl of stockinette, and find out which ribbing draws in the most for you.