When you make a pair of socks, usually, you want them to look like they are intended to be a pair. This doesn't always mean matching colour: hand-dyed sock yarns are almost impossible to match perfectly unless they have been dyed with that intent, and that is part of their charm. But, generally speaking, a pair of socks should be identical in terms of size and gauge. These tips will hopefully help you achieve this!
Obviously, it's important to have the same stitch counts between socks -- if you knit one sock at 60 stitches, and the second of a pair at 64, the difference will be slight but noticeable. If your pattern has multiple sizes, it's useful to indicate which of the sizes you're knitting, whether by highlighting or even a quick note. If all else fails, you can certainly double check yourself by counting the cuff stitches on the finished sock.
Maintaining the same number of rows for each part of the sock (the cuff, the leg, the heel flap, and the foot, is also important. Row counters can come in very handy here. As a general rule, if your memory is anything like mine, don't trust yourself to remember little details for the second sock -- by the time you get to that point, it's very likely that you'll forget and leave it out.
Since I'm very bad at using row counters, and will reliably lose any notes that I take on projects, I use a slightly different tool to get the same result. Multi-coloured locking stitch markers are probably my most used knitting tool besides my needles. When I knit 10 rows, I place a marker on the first sock in a colour that indicates the stitch pattern. If a section is not knit as a multiple of 10, I simply put a circular ring marker on the last clip for each row:
If I was knitting the second sock for the above pair, I can easily tell that the foot of the sock, from the pickup at the heel flap, needs exactly 54 rows. This method means that I never have to count more than 10 rows (which is, to be honest, about the limit of my attention span most days!). As an added bonus, keeping track of progress this way really does help the psychology of knitting -- there is definitely a mental "reward factor" in getting to place a marker every 10 rows and seeing evidence of progress during "black hole knitting" areas such as the leg and foot.
The good news is that, while using the above methods will give you identical socks, there's also nothing wrong with using a good ol' measuring tape and checking the length of each section as you knit. This will have a little room for error, since it's easy to add or lose a row or two when taking a measurement, but has perfectly serviceable results!
In my experience, it is preferable to use the same needles and circular technique for each sock in a pair. I like using magic loop for my socks, and while I'm comfortable using double pointed needles as well, there is a slight difference in tension that will show between the socks. Similarly, if I knit the first sock on my favourite red lace circulars, I would generally do my best to avoid knitting the second on bamboo or wood. So, as much as possible, keep the same needles (or same type of needles) and same technique between socks.
If you are knitting from a commercially printed sock yarn and want near-identical socks, when you cast on the first sock make sure to start at a colour or pattern transition point -- then, when you are ready to start the second sock, you just pull from the ball until you reach that same point. Having done this a number of times, the socks usually come out to identical within a few stitches so long as the same tension is used.
The last thing that I have found that helps across the board with getting reliable sock results is to take notes on your knitting. Those of you who post your work on social media platforms like Instagram, Facebook or Ravelry are already well-ahead of the game on this -- you have a visual record of what you knit and when you knit it. Adding details like the pattern name, stitches cast on, lengths, and any notable alterations that you made means that when the recipient of your hard work hopefully asks for another pair for their birthday or the holidays, you'll be able to reproduce the results without too much effort or covert foot measuring.
I am personally horrible at this. A glance at my personal Ravelry account would suggest that I have not knit anything in several years (which is rather far from the truth!), and I don't tend to use other platforms for much other than keeping in touch with out-of-town family members and friends. Instead, I have a notes file where I (try to) keep track of socks that I've made and the recipients, along with needle sizes and measurements. For example:
2020/05/20: 7bro, to DR steel blue plain for bd: On 3.75: 42/20C/30L 15HF/FRHeel 7.75" to start toe end with 7/7. /gusset@3sts mid bottom
This is not terribly legible to anyone but myself, of course, but if I am trying to reconstruct the blue pair of socks I gifted my mother-in-law for her birthday, I would be able to follow it without much difficulty.
In short, whatever method you use to keep track of your sock knitting is valid if it works for you -- just make sure that you do use some form of record in case your sock knitting gets interrupted and you find yourself staring at a half-finished pair wondering "How on earth do I reproduce this!?"