It seems that one could define homotopy almost all in category theory as follows:
Let $T$ be a terminal object and $I$ be some object. Let $i_0,i_1:T\rightarrow I$ be two maps. Suppose that $f,g:X\rightarrow Y$ are two morphisms. Let $\pi:X\times T\rightarrow X$ be the appropriate projection map. Call $X$ and $Y$ homotopic if there is a morphism $h:X\times I\rightarrow Y$ such that $$h\circ (\operatorname{id}_X\times i_0)=f\circ \pi$$ $$h\circ (\operatorname{id}_X\times i_1)=g\circ \pi$$
One can see that if we choose $I$ to be the unit interval, and $i_0$ and $i_1$ to be the maps sending a single point to either end of the interval, then this is the usual notion of homotopy equivalence.
However, I find myself bothered by the apparent necessity to choose $I$ and the maps $i_0$ and $i_1$. I seem to recall that I've read that there is some category theoretic property that identifies the interval as the appropriate choice for homotopy, but I cannot seem to find any (accessible) reference that makes such a construction.
Why is the interval used as $I$ in this construction?
My primary motivation for asking this is that I am interested in notions that look very similar to homotopy and which may be defined in other categories using appropriate choices of $I$ and $i_0$ and $i_1$ - but I'd like to know if there is some deeper property I ought to be looking for when making such a choice.