I was recording my bass in Garageband. After some recording, I created a new track, and the new regions in the track started playing in the wrong pitch (but at the correct tempo). I was able to make them play at the correct pitch by disabling "Follow pitch and tempo". All information I found around explains that the pitch may change, if you "Follow pitch and tempo", when you change song keys or tempo. But I never changed the initial pitch and tempo of my song. What could cause this? Why would the new track (by default) record and then play back in a different pitch?
These sorts of issues are often caused incorrect sample rate configurations. If your audio interface records the incoming signal at 44.1 kHz but your DAW believes that it is using 48 kHz, the pitch and tempo would be wrong.
You mentioned that the tempo is correct in your case so the cause might be something else, but it's worth checking the sample rates in your DAW and audio interface.
If you have "follow pitch and tempo" selected when adding audio to a track then Garageband will pitch shift and time stretch the new audio to try to match key and tempo with the existing contents of the track.
Obviously this involves some guesswork on Garageband's part, so if you know you're playing the notes you want when you want them then you should unselect this option.
A quick google will find you this video explaining how the option works.
I had the same issue in Cakewalk recently, and although it's a different DAW, I suspect the cause may be the same.
What I found was that after connecting a different microphone, or changing my audio inputs in some other way, it was necessary to tell the DAW to recalibrate my audio settings. Because of the complex calculations at various points in the analog to digital conversion, the existing settings were wrong in such a way as to alter the pitch. In my case the vocals came out a whole octave too high, but as soon as I used the DAW settings to recalibrate the audio based on the current hardware, all was well.