When I play the first fret of the 6th string of my electric guitar several times, the string makes an annoying sound, I think that it might hit another fret. It also happens with the 5th string but less frequently. What can I try to fix that ? Thank you
It sound like as Tom said fret buzz. I think you should take your guitar to a local lutier instead of trying to fix it by yourself because truss rod is very easy to break and it is quite expensive to fix it. If you are not very experienced with it you should take it to a lutiher. Furthermore electric guitars are designed to play together with an amplifier. Mine for example is creating buzz when I play it without an amplifier. Instead when I plug in I do not hear fretbuzz through amplifier. Maybe you should check it before bringing it to a luthier.
There really isn't enough info to give an informed answer. It is most likely a fret buzz but your guitar may not need an adjustment. If you are hitting the string too hard you will make it buzz. Even on a $5000 custom guitar set up by an expert! If you dig in with all your might you will make it buzz.
Also, If the frets are old you may have some indentations in a fret here and there and that will cause buzzing and dead spots regardless of the adjustment of the truss rod.
Check whether the buzz correlates to how hard you hit the string when you play. If not then there is a definite issue that needs to be looked at.
Look for dents in frets (probably should be step 1).
Bring the guitar into a local shop that does setups and ask someone to look at it (provided you don't want to do the adjusting yourself). They should be able to isolate the problem(s) and fix them.
If it is as the other answer says, then loosening the truss rod would alleviate it, and there's no danger of breaking anything.
The next simple solution would be to adjust the height of the bridge, using the screws on the saddles, assuming it's a Stratalike. There will be two tiny screws, usually moved using an Allen key, either side of the strings, where they cross the bridge. Screw the down, and the strings will rise, making more room under them at all frets, thus alleviating the problem.
Check with a straight-edge
Do you have an accurate straight edge? It could be the side of a credit card if that is long enough to span the frets in question. Otherwise find something else that is precisely straight that is a bit longer.
Looking sideways on to the fretboard, lay the straight edge along the frets. It should touch all the frets exactly. If it doesn't then one or more frets is high or low.
If this is the problem then there are various reasons. Other answers have mentioned worn frets and adjusting the height of the bridge. I'll talk about the following two.
(1) A fret is not fully down in its slot
(2) The neck is not straight
If you are confident with DIY and have suitable tools you may be able to correct a raised fret by lightly tapping it back into the slot. If you're not skilled, you may make things worse.
If the neck is not straight then you may be able to fix it by adjusting the truss rod. However if you are going to do that then you need to check the full length of the fretboard. You will need a rule (preferably steel) to check this. If the neck is obviously twisted or unevenly curved then this is a job for a professional.
Unless you are confident with such things then take the guitar to an expert and ask for a diagnosis and estimate of the cost before leaving it with them.