If a mapping $f:X \rightarrow S^4$ is not surjective, then it must be null-homotopic.
Why is this? I understand that if the map is surjective then it is not homotopic to the constant map because $S^4$ is not contractible. Can somebody explain this to me? Are there similiar situations for $S^2, S^3$ or $S^n$ for that matter? Thanks!
If $f:X\to S^4$ is not surjective, it misses a point $p\in S^4$. Since $S^4\setminus\{p\}\cong\mathbb R^4$ is contractible, the result follows.
Also, you state that a surjective map is not nulhomotopic, but this is not necessarily true. Let $f:\mathbb R^4\to S^4\setminus\{p\}$ be a stereographic projection. Take a small neighborhood $U$ of $p$, collapse this to a point via a map $g:S^4\to S^4$. Then the map $g\circ f:\mathbb R^4\to S^4$ is surjective, but also nulhomotopic, as $\mathbb R^4$ is contractible.
Lastly, the same two-sentence proof shows that for any $n\in\mathbb N$, if $f:X\to S^n$ is not surjective, then $f$ is nulhomotopic.