I am recording the audio with an aux cable connecting the Nintendo's headphone jack to my laptop's microphone jack adapter. The program I use is audacity.
Is there a way to separate the sound effects (i. e. button presses or attack sounds) and the background music into two audio tracks?
No, the audio is already mixed together when it is coming through the headphone jack. You would need to do it before it is mixed, but that requires modifying the game code which presumably you can't do.