If a reference can possibly be null, check it before you use it.
When comparing things like URLs and URIs that are supposed to be functionally equivalent regardless of case, use a case-insensitive comparison like string.equals("a", "A", StringComparison.InvariantCultureIgnoreCase) or even "a".ToUpper()=="A".ToUpper(), rather than the default "a"=="A".
The Javascript === vs == shitshow.
Floating point equality without an epsilon value.
Remembering to put in the # or . prefix when trying to select an element by id or class in css/jQuery selectors.
Understanding when database calls are actually triggered using your ORM of choice.
Using thread-safe containers when collections can be modified on one thread while they are being iterated over on another.
Treating rm -rf with extreme care.
After you run into an embarrassing bug that makes you look incompetent because you failed to account properly for these things, you develop a certain amount of OCD about it and internalize the checks. At least you should, or else you just end up making the same mistakes over and over. Of course, things can always fail in new and unexpected ways, so you are always adding to your corpus of fail.
As a last note, an incredibly help for me has been using static analysis tools that are built into tools like Resharper, Webstorm, IntelliJ, (basically anything made by JetBrains), Javascript linters, etc. You can offload a lot of the burden of correctness checking for the more trivial errors and gotchas to the machine, and focus on higher-level issues.