Let $X$ be contractible and $f\colon X\to Y$ be any map. Then we have a homotopy $H\colon X\times I\to X$ such that $H(x,0)=x$ and $H(x,1)=x_0$ for every $x\in X$ and some fixed $x_0\in X$. Consider the function $f\circ H\colon X\times I\to Y$. It is continuous being the composition of continuous functions. Further, $(f\circ H)(x,0)=f(H(x,0))=f(x)$ and $(f\circ H)(x,1)=f(H(x,1))=f(x_0)=:y_0$. Therefore, $f\circ H$ is a homotopy between $f$ and $y_0$. This proves
If $X$ is contractible, then any map $f\colon X\to Y$ is nullhomotopic.
In particular, this would means any map $I\to S^1$ is nullhomotopic. Doesn't this imply that $\pi_1(S^1)-0$? Where has my reasoning gone wrong?
Surely all maps $I \to X$ are nullhomotopic. But this has nothing to do with the fundamental group of $X$. In fact $$\pi_1(X,x_0)$$ requires the choice of a basepoint $x_0$ and consists of all path homotopy classes of closed paths $u : I \to X$ at $x_0$.
A closed path $u$ at $x_0$ is one satisfying $u(0) = u(1) = x_0$ and a path homotopy between two paths $u, v : I \to X$ having the same initial point $p_0 = u(0) = v(0)$ and the same terminal point $p_1 = u(1) = v(1)$ is a homotopy $H : I \times I \to X$ from $u$ to $v$ keeping $\partial I = \{0,1\}$ fixed which means that $H(i,t) = p_i$ for all $t \in I$, $i = 0,1$.
Of course any two $u, v : I \to X$ are homotopic, but even if they are closed paths at $x_0$ there is no reason to expect that they are homotopic rel. $\partial I$.