Complexity of cyclic sort
We can write each permutation of $1,\ldots,n$ in cycle notation, which will help us understand the behavior of the algorithm.

Suppose that $i = 1$. If $1$ is a fixed point, then the algorithm simply moves on. Otherwise, suppose that the cycle involving $1$ is $(1\;a_2\;a_3\;\cdots\;a_\ell)$, which means that $a_2 = A[1]$, $a_3 = A[2]$, ..., $a_\ell = A[a_{\ell-1}]$ and $1 = A[a_\ell]$. The algorithm will exchange $A[1]$ and $A[a_2]$, so that $A[1] = a_3$ and $A[a_2] = a_2$. This has the effect of removing $a_2$ from the cycle. After $\ell-1$ such steps, the cycle is no more, and $i$ will be increased.

If the permutation has cycles of lengths $\ell_1,\ldots,\ell_r$, then the total number of swaps performed by the algorithm is $(\ell_1-1) + \cdots + (\ell_r-1) = n-r \leq n-1$. This explains your observation that the maximum number of swaps is $n - 1$.

At each iteration of the main loop, either we perform a swap, or we increase $i$. The former can happen at most $n-1$ times, and the latter at most $n$ times. Since each iteration runs in time $O(1)$, in total the algorithm runs in $O(n)$.