A software instrument is a synthesized version of a real instrument. GarageBand has a wide range of these realistic sounds that can be controlled by the onscreen keyboard, or an external keyboard or guitar.
Using an Onscreen or External Keyboard
First, choose "New Track" from the Track menu. In the New Track window, choose the Software Instrument option and click "Create." Now click the i button in the lower right-hand corner to reveal the Track Info pane. Under Track Info, select an instrument type and instrument. Try playing the keyboard to see if you like the sound. Now to record yourself playing, simply click the record button (red dot) and push the play button to stop.
Using a Guitar
First, make sure that your guitar is correctly plugged into the audio input of your computer. Then in GarageBand, choose New Track from the Track menu. This time, choose the Real Instrument option and click "Create." In the Track Info pane, select "Guitars" and then choose the type of guitar sound you want in the right column. Next, select the "Monitor On" option and try playing your guitar. You should hear it through your Mac. Now you can record the guitar to a track.
Editing Software Instrument (MIDI) Data
To carefully edit what you have played in using a software instrument, or to even compose music without playing, open up the edit window by clicking on the scissors symbol in the bottom left-hand corner. In this window, you can choose to edit in the standard MIDI data edit mode (little blocks in a grid) or in the musical notation mode. To draw notes in, hold down the Command key (the cursor will turn into a pencil) and click the mouse wherever you'd like the notes to be.