Why do the N1 and N2 fans have different shafts?
Several reasons:

The fan, LPC/T, and HPC/T spools all operate at different speeds for optimal efficiency.  A hard link between them affects the speeds at which the other spools can operate, reducing efficiency.

Separate spools reduced the rotational inertia of each, reducing 'spool-up' lag, and allowing them quicker response times to throttle inputs.

The spools can be contra rotating, reducing the effective moment about the engine casing and mount, making the engine lighter.