Another factor is the frets on the guitar. Tall "jumbo" frets have more clearance between the top surface of the fret and the fingerboard. If you press down hard when you fret the string, the pitch might be pulled sharp. Tall frets have been popular on guitars for the last thirty years or so; "vintage" electric guitars tended to have small frets that are not nearly as tall.
Here is a diagram of the different kinds of frets available from Warmoth Custom Guitar Parts.
The "6230" and "6130" styles are similar to what was used on the earliest Fender and Gibson electric guitars, respectively. The tall "6150" style is perhaps the most commonly used on guitars made today. Tall frets are favored by "shredders" and those that bend strings a great deal.
If you have a guitar with tall jumbo frets, you can practice using less tension in your fretting fingers so you are not pressing the strings down all the way to the fingerboard. This is beneficial to your technique as well because you will experience less hand fatigue and it might facilitate playing faster.
You can also pay an experienced guitar repair technician to file your frets down lower, or to pull out the frets and replace them with smaller frets. This will be expensive.
Regardless, you should get a good professional "setup" on your guitar. This will improve the intonation overall. Here's my recent post about setups.
Keep these factors in mind:
1) Try a heavier gauge of strings
2) Learn to fret the strings with less tension in your fingers
3) Fret the strings directly behind each fret. Don't press down with your fingers in the middle of the fingerboard area between two frets. Doing so will mean that you are bending the string down too far and pulling it sharp.
4) If you can't compensate adequately with your fingering technique, you might want to see about getting smaller, lower frets on your guitar
5) If your electric guitar has a tremolo bridge set up to "float", you may want to get it set up to lie flat instead. A tremolo bridge set up to "float" might contribute to unsteady intonation unless you are very careful about your playing technique.
6) In all cases, get a professional "setup" to improve the intonation of your instrument overall and to set the optimal "action" for your playing technique.