Adding a knit-on border to a finished piece of knitting can give a pattern made of multiple blocks more cohesion, or it can just make an afghan or blanket look more finished.
For the purposes of this instruction I'm putting a border on a small knit swatch, but the exact same rules apply when knitting a border on an afghan.
To begin, choose your yarn that you want to use for the border, which can be the same as one used in the afghan or a coordinating yarn or color. Choose a circular knitting needle of the appropriate size for the yarn you're using, with a cable long enough to comfortably accommodate the number of stitches you'll have but short enough to work with without stretching the work too much.
Starting at any corner, pick up stitches along all four sides. On this swatch I picked up one stitch for every other stitch or row all the way around, except for picking up more stitches around the corners.
Playing with borders on swatches is a great way to learn what you like in terms of how many or how few stitches to pick up. It's also a good way to experiment if you might want to do a border of a particular pattern stitch and aren't sure how it will look.
If knitting a basic border like Garter Stitch, the number of stitches you pick up doesn't matter, though there should be a uniform number on corresponding sides. If you're knitting ribbing or a pattern stitch, ensure you pick up the right number of stitches to make the pattern work.