How can I make sure my holes are perfect
First, nothing is perfect. Machinists, cabinet makers, carpenters, all types of craftsmen work to certain tolerances. A rough carpenter may work to _+/- 1/8" or +/- 1/16". A machinist may use a variety of techniques to work to tolerances that are somewhat or a lot better than that: 0.010", 0.003", 0.001", 0.0005", or even better. But there will always be errors, nothing is perfect.
Techniques? OK.
First, a pencil will draw a line that is at least 0.010" wide and that is not very precise in machinist circles. It can be too big even for some fine wood work, like cabinet making. Machinists prefer scribed lines. The work is coated with a thin coat of a colored lacquer (die chem) and then a metal or carbide scribe with a fine point is used to draw lines in it. These lines can be around 0.002" or 0.001" wide and they provide a lot more precision. The colored lacquer provides a contrast to the bare metal exposed by the scribe so the lines stand out well.
I have a very good quality Starrett square but the lines on it also have a definite width so setting it to better than +/- 0.005" is difficult. Some here may say they can do better and I do not dispute them, but still the accuracy is limited.
The traditional method for scribing a part for machining is to use a surface plate and a height gauge with a scribe installed on it. The surface plate is extremely flat (+/- ten thousandths of an inch) and the height of the scribe above the plate can be precisely set with the vernier, dial, or digital scale that the height gauge is equipped with. With a method like this the lines can be easily located on the part with +/- 0.001" accuracy and with a good height gauge and some care you can do a lot better than that. In this process the width of the line becomes a major source of error.
For parts that do not need that level of accuracy, I often use a digital caliper to either directly mark the part, using the sharp edge of the jaws, or I transfer the setting from the caliper to one of my good adjustable squares and use that to scribe the lines. Of course, some additional error will creep in when you transfer a measurement like this.
Those are the two ways that I usually mark locations on parts.
The location for a hole is usually marked with two scribed lines that are at right angles to each other, forming a cross. Now a scribed line can be felt with a fine pointed instrument and I keep some good quality prick punches for making the first, SMALL punch mark at the hole's location. The punch is dragged lightly over the scribed lines, moving it perpendicular to both of them until the intersection is located. Then a light blow with a small hammer will make a small punch mark, hopefully on that intersection.
I use a 10X magnifier (Hastings Triplet is best) to examine that first, small prick punch mark to see if it is actually centered on the cross lines. If not, a punch is inserted in it and set at an angle to move the punch in the direction needed. This step takes some practice.
Once that initial, small punch mark is centered, a larger punch can be used to enlarge it to a size appropriate to the drill that you will be using. Generally this is around the web thickness of that drill so the drill sits in the punch mark when starting. Another tip here if your hole has a fairly large diameter is to use a smaller diameter drill to start the hole and then use the larger drill to follow the hole made by the smaller, initial drill. The theory here is that any drill, used with reasonable care and a punch mark for starting, will never drift more than it's radius off that mark and most often it will be centered far better than that. So, for instance, a 1/16" drill will never be more than 1/32" off and most likely it will be within a few thousandths. Then the larger drill will follow that initial hole and it will be centered equally well. But if you started with a 3/4" drill, it could easily drift off by 1/16" or even 1/8" if you are not really careful.
Many will tell you to use a spotting drill and I also like that idea. A spotting drill is a very short drill and it will not flex very much while starting the hole. You only make a dimple with it for the larger drill to follow.
All of the above takes time and if you need to work faster but with looser tolerances, another trick I use for centering holes on a part is to set an adjustable square to the calculated distance as best as I can and then I scribe lines from both opposite edges with it. The center will be half way between these two lines. This works well even when the width of your parts differs by a bit from one part to the next.