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 its the cast on, try a different method. Cable cast on usually is a good choice because its a knitted cast on and the tension will be closer to the rest of your knitting.
If its 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.
				
			
		Muchas gracias por compartir				
			
		Very nice, go on and well done. 				
			
		Thank you very much for sharing.				
			
		interessant 				
			
		Thank you very much for sharing.				
			
		 Very nice. Thank you for sharing!				
			
		Paylaşım için teşekkürler :)				
			
		thank you very much				
			
		If you want to have the rib without the flair, your are going to have to do some test knits.The way I do it on sweaters is to knit my rib, and then the first row of the stocking stitch, DECREASE (K2tog) evenly around after doing the rib.It looks like you wont have to do too much decreasing to get an even side,maybe 4-8 stitches, based on the picture.The best thing that you can do is swatch, or just knit smaller samples, with various decreases.Anyway, this is what I do frequently for my sweaters to get a straight side.My rib will be winder and then for the stockinette Ill decrease evenly around.Good luck with your testing.The hats are so cute.