$\textbf{Question:}$Does there exist an infinite sequence of integers $a_1, a_2, . . . $ such that $gcd(a_m, a_n) = 1 $ if and only if $|m - n| = 1$?
$\textbf{My solution:}$Suppose we have a $n$ element sequence that satisfies the condition.say $a_1,\cdots,a_n$. Now take $n-1$ distinct primes that divides none of the elements of this sequence.call the primes $p_1,\cdots,p_{n-1}$
Then the sequence $a_1p_1,\cdots,a_{n-1}p_{n-1},a_n$ also satisfies the condition. Now,simply take $a_{n+1}=p_1....p_{n-1}$. Then $a_1p_1,\cdots,a_{n-1}p_{n-1},a_n,a_{n+1}$ satisfies the condition.Hence,we can always increase the size of the sequence.
In addition $a,b$ with $(a,b)=1$ is a two element sequence that satisfies the condition.Hence we can form an infinite sequence that satisfies the given conditions.
If there is any flaw in my argument do tell me.
As has been pointed out, you show the existsnece of arbitrarily long finite sequences. To construct an infintie sequence, you must come up with a construction that leaves the old terms unchanged.
This should work: $$ a_n=p_{2n-1}p_{2n}\prod_{1\le i< 2n-3\atop i\equiv n\pmod 2}p_{i}$$ as $a_n$ and $a_{n-1}$ have no prime in common whereas one of $p_{2m-1},p_{2m}$ divides $a_n$ if $1\le m<n-1$.