You can use the loops and samples royalty free, even for commercial work. But you can only distribute the songs you created using the samples, not the loops or samples on a stand-alone basis, see: Using royalty-free loops in GarageBand with commercial work - Apple Support
"The GarageBand software license agreement says:
"GarageBand Software. You may use the Apple and third party audio loop content (Audio Content), contained in or otherwise included with the Apple Software, on a royalty-free basis, to create your own original music compositions or audio projects. You may broadcast and/or distribute your own music compositions or audio projects that were created using the Audio Content, however, individual audio loops may not be commercially or otherwise distributed on a standalone basis, nor may they be repackaged in whole or in part as audio samples, sound effects or music beds."
So don't worry, you can make commercial music with GarageBand, you just can't distribute the loops as loops.
Published Date: August 21, 2023"