Problem : If $\dfrac{d^2\vec{r}}{dt^2}=6t\hat{i}-24t^2\hat{j}+4\sin t \hat{k}$ and if $\vec{r}=2\hat{i}+\hat{j}$ and $\dfrac{d\vec{r}}{dt}=-\hat{i}-3\hat{k}$ when $t=0$, then show that $\vec{r}=(t^3-t+2)\hat{i}+(1-2t^4)\hat{j}+(t-4\sin t)\hat{k}$.
Try: We have \begin{align*} \dfrac{d^2\vec{r}}{dt^2}= 6t\hat{i}-24t^2\hat{j}+4\sin t \hat{k}\implies & d\left(\dfrac{d\vec{r}}{dt}\right)=(6t\hat{i}-24t^2\hat{j}+4\sin t \hat{k})\, dt \\ \implies & \dfrac{d\vec{r}}{dt}=3t^2\hat{i}-8t^3\hat{j}-4\cos t \hat{k}+ \vec{C}\\ \implies & \dfrac{d\vec{r}}{dt}=(3t^2-1)\hat{i}-8t^3\hat{j}-(4\cos t+7) \hat{k}\\ \implies & \vec{r}=(t^3-t)\hat{i}-2t^4\hat{j}-(4\sin t+7t) \hat{k}+\vec{D}\\ \implies & \vec{r}=(t^3-t)\hat{i}-2t^4\hat{j}-(4\sin t+7t) \hat{k} \quad [\because \vec{D}=\vec 0] \end{align*} which is different from the original result. But the given result is true. My derived result is also satisfies the given diff equn. Where is the problem?
It seems you made $2$ mistakes. First, with
$$\dfrac{d\vec{r}}{dt}=3t^2\hat{i}-8t^3\hat{j}-4\cos t \hat{k}+ \vec{C} \tag{1}\label{eq1A}$$
From $\dfrac{d\vec{r}}{dt}=-\hat{i}-3\hat{k}$ when $t=0$, you get
$$\begin{equation}\begin{aligned} -4\hat{k} + \vec{C} & = -\hat{i}-3\hat{k} \\ \vec{C} & = -\hat{i}+\hat{k} \end{aligned}\end{equation}\tag{2}\label{eq2A}$$
Thus, you would get
$$\dfrac{d\vec{r}}{dt}=(3t^2-1)\hat{i}-8t^3\hat{j}-(4\cos t-1) \hat{k} \tag{3}\label{eq3A}$$
It seems you subtracting $4\hat{k}$ on the right instead of adding it. Anyway, this is basically what the answer also states.
Near the end, using the correct derivative expression, you would get
$$\vec{r}=(t^3-t)\hat{i}-2t^4\hat{j}-(4\sin t-t) \hat{k}+\vec{D} \tag{4}\label{eq4A}$$
Using the initial condition $\vec{r}=2\hat{i}+\hat{j}$ when $t = 0$ gives
$$2\hat{i}+\hat{j} = \vec{D} \tag{5}\label{eq5A}$$
I don't know why you think $\vec{D} = \vec 0$. Using \eqref{eq5A} in \eqref{eq4A}, you would get
$$\begin{equation}\begin{aligned} \vec{r} & =(t^3-t+2)\hat{i}-(2t^4-1)\hat{j}-(4\sin t-t) \hat{k} \\ & = (t^3-t+2)\hat{i}+(1-2t^4)\hat{j}+(t-4\sin t)\hat{k} \end{aligned}\end{equation}\tag{6}\label{eq6A}$$
This matches what you're asked to show.