Why isn't DIV necessarily in P?
When we say that an algorithm runs in polynomial time, we mean polynomial in the length of the input to the algorithm, i.e., the number of bits needed to represent the input.  Suppose both $a$ and $b$ are at most $n$; then the pair $\langle a,b\rangle$ takes $\lg n$ bits to represent.  So, an algorithm whose running time is $O(n)$ takes exponential time (exponential in $\lg n$).  In particular, your algorithm is an exponential time algorithm.

The problem DIV is basically equivalent to the integer factoring problem.  It is an open question whether there exists any polynomial-time algorithm for it, but many believe that there probably is no polynomial time algorithm for it.