Maple correctly distinguishes between the n=4 and n≠4 cases because when n=4, the numerator and demominator of the summand in the Fourier series expansion of the solution are zero.
When calculating the Fourier coefficients by hand, one plugs in n=4 before carrying out the required integration. Maple attempts to "cheat" by calculating the coefficients for general n, and then taking the limit of the general term by letting n→4. That's where things go wrong because n→4 makes no sense when n is an integer.
To see what happens, consider
(-1 + (-1)^n) / (n-4);
limit(%, n=4);
Maple returns iπ. The reason for that may be seen more transparently by looking at the stripped-down case
(-1 + (-1)^x)/x;
limit(%, x=0);
where Maple again returns iπ. That makes sense because (-1)^x as x goes to zero makes no sense without bringing in complex numbers.