Knitting projects don't end as soon as you get them off your needle. There's always some finishing to do before you can declare yourself really, truly done. Even a one-piece project with no buttons or embellishments has at least one and usually two finishing steps. These steps are among foundational knitting techniques.
When you're learning finishing techniques, one of the first things to learn is how to block a knitted garment. Blocking is the process of shaping an item. Some knitted items almost call for not having the structure blocking will provide, but items you want to have a straight edge, like a blanket, will look better after you block. To block any item, get it wet. Then lay it out on a flat surface that you can stick straight pins into. I lay a thick layer of towels down on my guest room bed. You can also use blocking mats. Then gently shape your project and use straight pins to tack down the edges. To finish a knitting project you want to be relatively square, measure your dimensions as you lay out your project. If you aren't having success, the likeliest problem is that your project isn't wet enough.
If you're making a project that has multiple pieces, it's a good idea to block them separately before sewing them together.
One finishing step for any knitted item is to weave in all the yarn ends. This is always the absolute last thing I do (other than felting). I don't like to weave in ends before blocking because as I stretch out my project, those ends might come loose a little.
Everywhere you look, you'll be told to do this, but it's rare to find tips on how. The Craftsy Knit Lab class has a lesson on it. (It also covers basic blocking.) The idea is to weave the yarn tails that are at the beginning and end of your project as well as wherever you worked in a new ball of yarn so that all your hard work won't come undone. If your work has a clear wrong side, you need to work your ends on that side.
I try to make my weaving follow the flow of the knitting, working horizontally along purl bumps. I find this makes the ends as unobtrusive as possible. You don't want it to be obvious where the ends are woven. Some knitting calls for working with two skeins of yarn at a time, so you have two ends to weave in each spot. In that case, I don't weave the ends together, but work them separately, taking them in different directions. I also like to work each end on different rows and switching directions. So I might work it out horizontally for 5 stitches and then switch to the next row and work back 5 stitches. (I can be a bit zealous in my end-weaving, but my projects never unravel!)
These are the steps I follow when I'm finishing a knitting project. If I have any buttons to sew on, I do that last. No matter what the exact last step is, it always feels so good to finish another knitting project!
As you think about finishing your knits, you might enjoy the online Craftsy class Button Bands & Buttonholes.