Is it possible to prove that a general purpose integer factorization algorithm must contain a loop?
It depends on the precise model of computation you work within.  However, this doesn't seem to be a useful direction for proving lower bounds on the time to factor.

Uniform algorithms

Let's look at uniform algorithms.  Suppose our model of computation is a Turing machine or the transdichotomous model or something similar, where each step can do at most a constant amount of work (or a logarithmic amount of work).  Then any such algorithm must contain a loop or backward branch.

(Why?  Such an algorithm must work on inputs of all possible lengths.  The algorithm has finite length, say length $k$.  If there are no loops or backward branches, then this means that any execution of the algorithm must involve at most $k$ steps, where $k$ is fixed.  This means there exists $n$ large enough so that, when the input is $n$ bits long, the algorithm can't even read the entire input using $k$ steps of computation. Consequently, any such algorithm without loops cannot possibly be correct on all inputs.)

This doesn't seem useful for proving non-trivial lower bounds on the complexity of factoring.

Non-uniform algorithms

Non-uniform algorithms don't require loops.  In particular, if there is a non-uniform algorithm (possibly with loops) that takes $T(n)$ time on $n$-bit inputs, then there is a non-uniform algorithm without loops that takes $O(T(n)^2)$ time on $n$-bit inputs and has size $O(T(n)^2)$.

(Why?  Simply unroll all loops.  Since the algorithm takes $T(n)$ time, each loop will execute at most $T(n)$ times, so you can unroll it and make $T(n)$ copies.)

Other notes

Your question claims "there must be an if-then statement which tests if $1&lt;x&lt;n$, $x|n$ or any other mathematically equivalent test", but this claim is not justified and I don't think it is correct.  There could be algorithms that contain a loop with some other loop condition.  Also, your heuristic is clearly false.  The output of $\gcd(a_i,n)$ isn't anything like a uniformly distributed number from $\{1,\dots,n\}$.  So the direction you're taking seems like it is based on faulty premises and seems like a dead end.