Try a choice, explore where it leads, undo it, and try the next one.
Walking through a maze with chalk: at each fork you pick a path and keep going. If you hit a dead end you walk back to the last fork (backtrack), rub out your chalk mark and take the other path. Backtracking systematically tries every possibility but gives up on a branch as soon as it cannot work.
The pattern is always: choose → explore (recursion) → un-choose. Subsets: for each item decide “take it” or “skip it”. N-Queens: place one queen per row; if a square is attacked, skip it; if a row has no safe square, go back and move the previous queen.
append(res, path) shares memory that is changed later. Copy: append([]int{}, path...).Subsets: O(2n) results, so O(n·2n) time to build them. N-Queens: worse than polynomial but pruning (skipping attacked squares early) cuts the search enormously compared with trying all placements. Space: O(n) recursion depth plus the stored results.