How can I improve my attention and make fewer mistakes?
I was unfortunate enough to grow up in an academic upbringing (almost from pre-school up until university) that is a) purely competitive and b) relies solely on multiple-choice exams. 

We were drilled for years to try and avoid such small mistakes, since they prove to be extremely costly when millions of people take the same test. 

My only advice to you is to make a habit of checking your work, with a clear set of mind. I know it's not always possible (usually due to lack of time) but it's a very important skill to keep in mind that such mistakes do happen from time to time, and having some time at the end of a test/experiment entirely dedicated to checking your work is "money". 

To my knowledge there is no fail-safe way to avoid such mistakes. Humans aren't really designed (from an evolutionary point of view) to stay focused for extended periods of time, especially when implicit calculations occur. Which brings me to a "corollary" advice; make a habit of writing out all your thoughts/calculations explicitly. The benefit with that is that it allows you to immediately spot irregularities in your work when you go back and check your work later prior to the point-of-no-return (i.e. you hand in your exam, or turn on the electricity switch or whatever).