Both “次” and “遍” firstly refer to “times”, but they differ in the deep implication and usage.
次:To describe that one thing repeatedly appears. If it was followed by a concrete address we could use “次” to show the frequency.
遍:To describe the whole process of an action from the beginning to the end.