Why is the complexity of the following code $O(n^4)$?
There are two things that could be measured here. First, the time complexity of the code, which is to say the number of steps it takes to execute. In that case we have two possible metrics: (1) count each arithmetic operation as taking 1 unit of time. That's the one you're likely used to. In (2) we count the time an arithmetic operation takes as a function of the number of bits needed to express the operands.

The second possibility is to measure the magnitude of the result, $r$, as a function of $n$. It appears that your professor is looking for the second measure: express $r$ in terms of $n$. That, though, is a bit problematic, since $s$ is reset to zero at each iteration of the outer loop, so the final value of $r$ is just the result when $i=n$ which will be $O(n^6)$.

The upshot is that your calculation of the running time, $O(n^2)$ is the only one that makes any sense here. Ask your professor for clarification.