The problem might be caused by loose cast on, or the ribbing itself is loose because of loose purl stitches or from the moving the yarn back and forth loosely from knitting and purling. Experiment with yarn scraps to find the problem.|
If it's the cast on, try a different method. Cable cast on usually is a good choice because it's a knitted cast on and the tension will be closer to the rest of your knitting.
If it's the rib stitch itself, one way to tighten it is to knit the knits through the back loop but keep purling normally. This is called the twisted rib stitch, and the first photo you posted looks like it used this stitch.