You can use your electric guitar to record to real instrument tracks, because it will output an audio signal. The audio tracks are shown in blue in the "New Track" dialog. Software instrument tracks can be played as any instrument (piano, flute, etc). To record to software instrument tracks you need a device, that will send midi to GarageBand - just the notes and articulation (attack, note velocity, etc.). You can record midi instruments on software instrument tracks. They are shown in green. A midi keyboard would be best to play any software instrument. Or enter key combination ⌘K to open the the musical typing keyboard. then you can use the letters on the keyboard of the Mac to enter notes. The letters on the displayed keys on the musical typing keyboard tell you which note later to type on your Mac's keyboard.

Some third party software can output midi files, when you play a guitar. But it is bit expensive. Logic Pro X can create a midi track from an audio track, or Finale lets you create midi while listening to an instrument you are playing. There are also midi guitars.